0

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.

Phab
  • 1,623
  • 9
  • 15

2 Answers2

1

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]
Basheer Algohi
  • 19,917
  • 1
  • 31
  • 78
  • same answer as Kuba, but it's not only about the Point[], it's about PlotOptions in general. – Phab Jun 24 '14 at 14:55
  • 1
    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. – Basheer Algohi Jun 24 '14 at 15:00
0
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)

kglr
  • 394,356
  • 18
  • 477
  • 896