看看这样做你想要什么。我只是使用ListPlot而不是plot。
但我不确定你在做什么,因为你正在绘制f
c从0到1,但是然后将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)
它只是发生在我身上,使上面的更高效,是使用第一个表的命令,以生成数据本身,而不仅仅是查找绘图范围的最大/最小值。然后用ListPlot
代替Plot
。这应该更快,所以功能f
的采样只发生一次而不是2次?
因此,这里是第二个版本
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]
)
]
如果有方法将PlotRange添加到Manipulate中,我会非常棒,但到目前为止我还没有发现任何说这是可能的... – CaptanFunkyFresh 2012-01-09 22:51:33