0
$\begingroup$

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.

$\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$
    – Nasser
    Sep 12, 2022 at 0:44

1 Answer 1

2
$\begingroup$

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}
]

enter image description here

$\endgroup$
2
  • $\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$
    – MarcoB
    Sep 14, 2022 at 1:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.