Is there a way to layer a static plot over a manipulated plot? So I could, for instance, show a red point moving along a sin curve, superimposed over a static plot of the sin. I tried this but the manipulated plot won't turn up in Show, which complains it's not a plot.
$\begingroup$
$\endgroup$
1
-
2$\begingroup$ Yes, ofcourse you can. But why not just generate the sin plot each time? Why does it have to be pre-drawn outside the Manipulate? Also it will be better to show what you tried, even if it does not work. That will give something to start with and get better idea what you are trying to do. $\endgroup$– NasserSep 12, 2022 at 0:44
Add a comment
|
1 Answer
$\begingroup$
$\endgroup$
2
Here is an example:
sin = Plot[Sin[x], {x, -3 Pi, 3 Pi}];
Manipulate[
Show[
sin,
Graphics[{Red, PointSize[0.04], Point[{x, Sin[x]}]}]
],
{x, -3 Pi, 3 Pi}
]
-
$\begingroup$ Thanks. That's a more compact way of doing it than I found. While I was waiting, I figured out how to do it with Epilog - but it's more obtuse: Manipulate[ Plot[{Sin[c x], Cos[x]}, {x, 0, 2 Pi}, PlotRange -> {-1, 1}, Epilog -> {PointSize[Large], Point[{n, Cos[n]}]}], {c, .565, 3}, {n, 0, 2 Pi}] $\endgroup$ Sep 13, 2022 at 20:33
-
$\begingroup$ @cybervigilante Your approach makes sense as well, as long as the static plot is not time consuming. $\endgroup$– MarcoBSep 14, 2022 at 1:02