Group Abstract Group Abstract

Message Boards Message Boards

Include multiple Plots with Show & ListPlot into Manipulate?

Posted 9 years ago

Hi All, How do I include multiple Plots with Show & ListPlot into Manipulate & also showing PlotMarkers, Ticks & Grids marks. Given the coding for a static Plot / ListPlot :- This is what I want to have as Manipulate plot.

Show[ListPlot[Table[{i, 2 i}, {i, 5}], PlotMarkers -> {"X"}, Ticks -> {Table[i, {i, 1, 5}], Table[2 i, {i, 1, 5}]}, 
GridLines -> {Table[i, {i, 1, 5}], Table[2 i, {i, 1, 5}]},
PlotRange -> {{-1, 7}, {-5, 15}}, ImageSize -> Large], Plot[{2 x, (6 - x)*5}, {x, 0, 6}, 
PlotRange -> {{-1, 7}, {-5, 32}}, PlotStyle -> {Thin, Automatic, Red, Dashed}, ImageSize -> Large]]

I tried but my Manipulate / Plot does not allow slider movement. See & review coding below.

Manipulate[ Show[ListPlot[Table[{i, 2 i}, {i, 5}], PlotMarkers -> {"X"}, Ticks -> {Table[i, {i, 1, 5}], Table[2 i, {i, 1, 5}]}, 
GridLines -> {Table[i, {i, 1, 5}], Table[2 i, {i, 1, 5}]}, PlotRange -> {{-1, 7}, {-5, 32}}, 
ImageSize -> Large], Plot[{2 x, (6 - x)*5}, {x, 0, 6}, PlotRange -> {{-1, 7}, {-5, 32}}, 
PlotStyle -> {Thin, Automatic, Red, Dashed}, ImageSize -> Large, Epilog -> {PointSize[0.03], 
Point[{a, (6 - a)*5}], Point[{a, a*2}]}]], {{a, 30/7}, 0, 6}, Button["reset", a = 30/7]]

Here is a simple version of the Manipulate that works below, but I want to include PlotMarkers, Ticks & Grids to the Manipulate plot.

Manipulate[ Show[Plot[{2 x, (6 - x)*5}, {x, 0, 6}, PlotRange -> {{-1, 7}, {-5, 32}}, ImageSize -> Large, 
Epilog -> {PointSize[0.03], Point[{a, (6 - a)*5}], Point[{a, a*2}]}]], {{a, 3}, 0, 6}, Button["reset", a = 30/7]]

Many thanks for any help you can offer. Greatly appreciated. Best regards, Lea...

Attachments:
POSTED BY: Lea Rebanks
6 Replies

Hi,

does this work for you?

Manipulate[Show[Plot[{2 x, (6 - x)*5}, {x, 0, 6}, PlotRange -> {{-1, 7}, {-5, 32}}, ImageSize -> Large, Epilog -> {Black, PointSize[0.03], Point[{a, (6 - a)*5}], Point[{a, a*2}]}, PlotStyle -> {Thin, Automatic, Red, Dashed}, GridLines -> {Table[i, {i, 1, 5}], Table[2 i, {i, 1, 5}]}], 
ListPlot[Table[{i, 2 i}, {i, 5}], PlotMarkers -> {"X"}, Ticks -> {Table[i, {i, 1, 5}], Table[2 i, {i, 1, 5}]}, PlotRange -> {{-1, 7}, {-5, 32}}, ImageSize -> Large]], {{a, 30/7},0, 6}]

enter image description here

Cheers,

M.

POSTED BY: Marco Thiel
Posted 9 years ago

Perfect. Thanks so much. It is so close to my coding, I will review carefully.

FYI - PlotStyle -> {Thin, Automatic, Red, Dashed} plots a Blue line. Don't know why ???

POSTED BY: Lea Rebanks

FYI - PlotStyle -> {Thin, Automatic, Red, Dashed} plots a Blue line. Don't know why ???

I suppose that you need to wrap the options into a "Directive":

Manipulate[
 Show[Plot[{2 x, (6 - x)*5}, {x, 0, 6}, 
   PlotRange -> {{-1, 7}, {-5, 32}}, ImageSize -> Large, 
   Epilog -> {Black, PointSize[0.03], Point[{a, (6 - a)*5}], 
     Point[{a, a*2}]}, 
   PlotStyle -> Directive[Thick, Red, Automatic, Dashed], 
   GridLines -> {Table[i, {i, 1, 5}], Table[2 i, {i, 1, 5}]}], 
  ListPlot[Table[{i, 2 i}, {i, 5}], PlotMarkers -> {"X"}, 
   Ticks -> {Table[i, {i, 1, 5}], Table[2 i, {i, 1, 5}]}, 
   PlotRange -> {{-1, 7}, {-5, 32}}, ImageSize -> Large]], {{a, 30/7},
   0, 6}]

I have substituted "Thin" by "Thick" do see it a bit better.

Cheers,

M.

POSTED BY: Marco Thiel
Posted 9 years ago

Many thanks Marco! All very helpful. Really appreciated.

POSTED BY: Lea Rebanks
POSTED BY: Bianca Eifert
Posted 9 years ago

Many thanks Bianca. I appreciate your help. Best regards, Lea...

POSTED BY: Lea Rebanks
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard