# A few specific questions on a number of plots in a do loop

I have created the picture displayed below, with the following line of code:

Colors = List[Brown, Red, Orange, Yellow, Green, Blue, Pink, Purple, Black];
Show[Table[
Plot[Part[list, i, 2]*Prob[Part[list, i, 2]*n] /. {y -> a,
z -> Part[list, i, 3]}, {n, 0, 3},
PlotStyle -> {Thick, Part[Colors, i]}], {i, Length[list]}],
PlotRange -> {All, {0, 1.2}}]


The array list just contains sum numbers of the form { {a,b,c}, {c,d,e}, ...} and Prob is just some function, with constants y and z which I specify in the above. There are a few questions I have concerning this code:

-Note that the axis of the graph appears to lie above zero. I would like to make a graph with its x axis really at y=0. How to do this?

-I would like to give every graph in the picture a different label, which is stored in Part[list, i,2]. However, I have two problems: PlotLegends gives an error and I only know how to include text between " ", not a number which is determined by the running of the do loop.

Any help is very much appreciated!

• Regarding the axes look for AxesOrigin like Plot[Sin@x, {x, 0, 1}, AxesOrigin -> {0, .5}]. Regarding PlotLegends: are you on V9 or on V8?
– Öskå
Nov 21, 2013 at 16:51
• @Öskå Thanks, AxesOrigin works! I am on V8 at work and on V9 at home :) Nov 21, 2013 at 16:54
• PlotLegends only works on V9. For the V8 you have to import PlotLegend (which is pretty ugly!) or use autoLegend from here
– Öskå
Nov 21, 2013 at 16:57

You do not need to create the plots individually and then combine them with Show. You can specify the options as lists and one of the comments already tells you how to position the axes origin.

functions = {x, x^2};
legends = Table["function " <> ToString[i], {i, 2}];
Plot[functions, {x, 0, 1}, PlotStyle -> styles,
PlotLegends -> legends, AxesOrigin -> {0, 0.6}]


• Thanks, this was very useful. I have but one last question: if I use your method and I save the graphic, the legend is not included. How do I included it when I export the graph as a picture? Nov 21, 2013 at 20:43
• @Funzies: Are you exporting by selecting only the graph and the using the menu commands or are you exporting with Export[FileNameJoin[{\$TemporaryDirectory, "test.png"}], Plot[functions, {x, 0, 1}, PlotStyle -> styles, PlotLegends -> legends, AxesOrigin -> {0, 0.6}]]? Nov 22, 2013 at 13:20