看看这个能否满足你的需求。 我只是使用ListPlot而不是plot。
但我不确定你在做什么,因为你正在绘制f
从0到1的c,但是然后将x范围设置为仅从0到0.05?为什么不直接使用{c,0,0.05}
绘制f
呢?也许我漏掉了什么。
无论如何,这就是我拥有的。
Manipulate[
xmax = 0.05;
y = Table[f[a, b, c], {c, 0, xmax, 0.01}];
max = Max[y];
min = Min[y];
Plot[f[a, b, c], {c, 0, 1},
PlotRange -> {{0, xmax}, {min, max}}, ImagePadding -> 30],
{a, 0, 1},
{b, 0, 1},
Initialization :>
(
f[a_, b_, c_] := a b c Exp[a b]
)
]
编辑(1)
我突然想到,为了使上述过程更加高效,可以使用第一个Table命令来生成数据本身,而不仅仅是找到图表范围的最大/最小值。然后使用ListPlot
而不是Plot
。这样应该会更快,因为对函数f
的采样只发生一次,而不是两次?
所以这是第二个版本。
Manipulate[xmax = 0.05;
data = Table[{c, f[a, b, c]}, {c, 0, xmax, 0.01}];
max = Max[data[[All, 2]]];
min = Min[data[[All, 2]]];
ListPlot[
data,
PlotRange -> {Automatic, {min, max}},
Joined -> True,
ImagePadding -> 30
],
{a, 0, 1},
{b, 0, 1},
Initialization :>
(
f[a_, b_, c_] := a b c Exp[a b]
)
]