0
$\begingroup$

This question already has an answer here:

I try to find a way to manipulate a plot I created before.

(for full code take the fuction

x[t_]:=Sin[2t]

)

Let's say I have a plot:

plot1 = Plot[x[t], {t, 0, 10},
   PlotStyle -> Purple,
   ImagePadding -> 55,
   Frame -> {True, True, True, False},
   FrameStyle -> {Automatic, Purple, Automatic, Automatic},
   FrameLabel -> {None, "Signal", None, None},
   LabelStyle -> {16},
   ImageSize -> 600
   ];

And later I want to use the same plot with a point on the line. The complete code would be:

plot1 = Plot[x[t], {t, 0, 10},
   PlotStyle -> Purple,
   ImagePadding -> 55,
   Frame -> {True, True, True, False},
   FrameStyle -> {Automatic, Purple, Automatic, Automatic},
   FrameLabel -> {None, "Signal", None, None},
   LabelStyle -> {16},
   ImageSize -> 600,
   Epilog -> {Directive[{Purple}],PointSize -> Large,Point[{2,
   x[2]}]}
   ];

But is there another way? Something like

SetOptions[plot1,Epilog -> {Directive[{Purple}], PointSize -> Large, 
  Point[{2, x[2]}]}]

And what if I want to use this plot the second time in a Manipulate[] environment?

Manipulate[plot1,{dt,0,10}]

Till now I couldn't find a way to do this.

$\endgroup$

marked as duplicate by Jens, ciao, Michael E2, m_goldberg, Yves Klett Jun 25 '14 at 5:12

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 2
    $\begingroup$ Try Show, if I get it right. $\endgroup$ – Kuba Jun 24 '14 at 14:39
  • $\begingroup$ @Kuba That's it! Does everything I need ... for now $\endgroup$ – Phab Jun 24 '14 at 14:44
  • $\begingroup$ @Kuba What if I want to change the PlotStyle? Let's say from Purple to Red? $\endgroup$ – Phab Jun 24 '14 at 14:57
  • 1
    $\begingroup$ Then you have to do something like 17250 $\endgroup$ – Kuba Jun 24 '14 at 14:58
  • $\begingroup$ I think the original question is arguably "easily found in the documentation" and the extended question is addressed in Is it possible to change the color of plot in Show? (as Kuba already linked). Either way I favor closing this question. $\endgroup$ – Mr.Wizard Jun 24 '14 at 18:44
1
$\begingroup$

Try this:

Manipulate[
 Show[plot1, 
  Graphics[{PointSize[0.02], Purple, Point[{a, Sin[2 a]}]}]], {a, 0, 
  10}]

some thing else may be helpful.

LocatorPane[Dynamic[pt], 
 Show[plot1, 
  Graphics[{PointSize[Large], 
    Point[Dynamic[{First[pt], Sin[2 First[pt]]}]]}]], 
 Appearance -> None]
$\endgroup$
  • $\begingroup$ same answer as Kuba, but it's not only about the Point[], it's about PlotOptions in general. $\endgroup$ – Phab Jun 24 '14 at 14:55
  • 1
    $\begingroup$ I don't think there is option in Plot in which you edit an existing plot or picture. the only option is to treat the created plot as image and use other functions that work with images. $\endgroup$ – Algohi Jun 24 '14 at 15:00
0
$\begingroup$
plot1 = Plot[Sin[t], {t, 0, 10}, PlotStyle -> Purple, 
   ImagePadding -> 55, Frame -> {True, True, True, False}, 
   FrameStyle -> {Automatic, Purple, Automatic, Automatic}, 
   FrameLabel -> {None, "Signal", None, None}, LabelStyle -> {16}, 
   ImageSize -> 600];

Manipulate[Graphics[{
                    plot1[[1]] /. Purple -> Directive[{Thick, Red}], 
                    PointSize -> Large, Point[{a, Sin[a]}]
                    }, 
       Frame -> {{True, True}, {True, False}}, 
       LabelStyle -> Directive[Italic, Large], AspectRatio -> 1/3, 
       plot1[[2]]], {a, 0, 10}]

enter image description here

There is also Experimental`Explore[] (see this answer by rm-rf) if you have Version 8 (but it does not work with Version 9.0.1.0, Windows 8)

$\endgroup$

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