Message Boards Message Boards

Include multiple Plots with Show & ListPlot into Manipulate?

Posted 8 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 8 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 8 years ago

Many thanks Marco! All very helpful. Really appreciated.

POSTED BY: Lea Rebanks

Marco is right. PlotStyle -> {Thin, Automatic, Red, Dashed} plots the first line Thin, the second Automatic, the third Red, and the fourth Dashed. For each line, all other properties keep their default values, so the thickness of lines 2, 3 and 4 is the standard one, the colours are the standard ones except for line 3, and so forth. (If your plot has less than 4 lines, you won't see all these styles, so it may look even more confusing.) By the way, if you do need multiple styles for different functions, you can use Directive inside a list of styles as well, such as PlotStyle->{Red,Directive[Green,Dashed],Blue}.

POSTED BY: Bianca Eifert
Posted 8 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

Group Abstract Group Abstract