Here is the code:
Dynamic@Show[{Graphics[{LightGray, Rectangle[{0, -1}, {Pi, 1}]}],
Plot[Sin[a x], {x, 0, Pi}]}]
Slider[Dynamic[a]]
The Slider controls the value of a
in Plot[]
to produce a dynamic plot of Sin[]
.
I would like to make the Plot[]
dynamic only, but it didn't work if i only wrapped plot[]
with dynamic[]
, so i added dynamic to the whole show[]. So how to dynamically update plot[]
solely?
Manipulate[Plot[Sin[a x], {x, 0, π}, PlotRange -> {{0, π}, {-1, 1}}, Prolog -> {LightGray, Rectangle[{0, -1}, {π, 1}]}], {{a, 1}, -2, 2, 0.01, Appearance -> "Labeled"}]
$\endgroup$ – Bob Hanlon Sep 19 '20 at 4:46Slider[Dynamic[a]]
gr = Graphics[{LightGray, Rectangle[{0, -1}, {Pi, 1}]}]; Dynamic[Show[gr, Plot[Sin[a x], {x, 0, Pi}]]]
$\endgroup$ – Bob Hanlon Sep 19 '20 at 5:24