Mathematica Asked on May 19, 2021
I am using Manipulate to plot a function that takes a fair amount of time to be plotted. Once it is done I would like to change the y-range where it is plotted. To avoid that the function is evaluated again I am trying to use Dynamic. Following an example in Wolfram Documentation I constructed something like this:
Manipulate[
Plot[f[a,x],{x,0,xmax},PlotRange->Dynamic[{0,xmax}]],
{a,amin,amax},{xmax,0.1,5}
]
However, I get an error:
General::prng: Value of option PlotRange -> {0,0.1} is not All,
Full, Automatic, a positive machine number, or an appropriate list of
range specifications.
Any ideas on how to solve this?
This version recomputes f[a, x]
when the y-range is changed
f[a_, x_] := a Sin[x]
{amin, amax} = {1, 2};
Manipulate[Plot[f[a, x], {x, 0, xmax},
PlotRange -> {{0, xmax}, {ymin = -ymax, ymax}}],
{a, amin, amax}, {xmax, Pi, 2 Pi}, {ymax, 2, 6}]
However, in this version the y-range is fixed ...
f[a_, x_] := a Sin[x]
{amin, amax} = {1, 2};
ymax = 2;
Manipulate[plot = Plot[f[a, x], {x, 0, xmax},
PlotRange -> {{0, xmax}, {ymin = -ymax, ymax}}],
{a, amin, amax}, {xmax, Pi, 2 Pi}]
but it can be rescaled in a further manipulate without recalculation.
Manipulate[plot /.
(PlotRange -> {i_, {j_, k_}}) :> (PlotRange -> {i, {-m, m}}),
{m, 2, 4}]
Answered by Chris Degnen on May 19, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP