# Append plots from Manipulate

Let's say I have a function which has some parameters c and b associated with it,

Fx[b_, c_, y_, x_] := Sin[x/c] + Cos [b y]


For each value of c and b I want to be able to append all the graphs on top of each other using manipulate function. Right now I'm using Show function to plot all on top of each other, For {b= 2,4,6} and {c=1,5,10}

F1 = Plot[ Sin[x/2] + Cos [12 1], {x, -100, 100} , PlotStyle -> Green , PlotRange -> Automatic]
F2 = Plot[Sin[x/4] + Cos [12 5], {x, -100, 100} , PlotStyle -> Red , PlotRange -> Automatic]
F3 = Plot[Sin[x/6] + Cos [12 10], {x, -100, 100} , PlotStyle -> Blue , PlotRange -> Automatic]


and use show

Show[F1, F2, F3, PlotRange -> Automatic]


or using manipulate

Manipulate[Show[F1, F2, F3, PlotRange -> {{x1, x2}, {y1, y2}}], {x1, -100,100}, {x2, -100, 100}, {y1, -1, 1}, {y2, -1, 1}]


And I see the plots , but it is time consuming if I have lets say 40 values for parameters b , c. So I tried to use manipulate with Show instead of Plot, I redefined my functions as Such:

H1[x_, y_, b_, c_] := Plot[ Sin[x/b] + Cos [12 c], {x, -100, 100} , PlotStyle -> Green , PlotRange -> Automatic];
H2[x_, y_, b_, c_] := Plot[ Sin[x/b] + Cos [12 c], {x, -100, 100} , PlotStyle -> Blue ,  PlotRange -> Automatic];
H3[x_, y_, b_, c_] = Plot[ Sin[x/b] + Cos [12 c], {x, -100, 100} , PlotStyle -> Red , PlotRange -> Automatic]


and used this manipulate code:

Manipulate[Show[{H1, H2, H3}, PlotRange -> Automatic], {b, 1, 10}, {c, 1,10}]


Of course I can use manipulate to change the parameters

Manipulate[Plot[ Sin[x/c] + Cos [12 b], {x, -100, 100} , PlotStyle -> Red , PlotRange -> Automatic], {c, 1, 10}, {b, 1, 10}]


Which works fine, but then I could only copy the graph for each value but I can't append them on top of each other, So I thought maybe I can use manipulate with Show instead of plot.

I was wondering if there is a way to use manipulate function for each value of parameters such that the graph with one value saves and when select a new parameter value graph will automatically append on previous graph in other words every graph for given value freezes in single plot (with different plot style i.e. color and thickness)

Thank you,

• Cross-posted: community.wolfram.com/groups/-/m/t/1313104 Apr 2, 2018 at 3:16
• Apr 2, 2018 at 3:19
• Thanks for letting know Apr 2, 2018 at 4:22

will automatically append on previous graph

I am not sure I understand exactly, but you want to append the plots in show? Why not use AppendTo then?

Manipulate[
p=Plot[Sin[w x],{x,-5 Pi,5 Pi},PlotRange->All];
AppendTo[myPlots,p];
Show[myPlots],

{{w,.1,"w"},0.01,1,.01,Appearance->"Labeled",ContinuousAction->False},
Button["Clear All",myPlots={}],

{{myPlots,{}},None},
TrackedSymbols:>{w}
] And if you want to show current plot and all previous plots at same time

Manipulate[
p=Plot[Sin[w x],{x,-5 Pi,5 Pi},PlotRange->All,ImageSize->300];
AppendTo[myPlots,p];

Grid[{{p},{Show[myPlots]}},Frame->All,Spacings->1],

{{w,.1,"w"},0.01,1,.01,Appearance->"Labeled",ContinuousAction->False},
Button["Clear All",myPlots={}],

{{myPlots,{}},None},
TrackedSymbols:>{w},
SynchronousUpdating->False
] • This looks pretty awesome thanks, would be better if each plot has a different color , Also clear button doesn't really clean all unless you change the value Apr 2, 2018 at 0:07
• @RacaioCmoto yes. But this was a quick thingy, just to show the idea. I assume you can customize it as you need and make more improvements. Apr 2, 2018 at 0:34
• Sure, I will do,, thanks, Apr 2, 2018 at 2:10