Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

Colors = List[Brown, Red, Orange, Yellow, Green, Blue, Pink, Purple, Black];    
      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!

enter image description here

share|improve this question
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 '13 at 16:51
@Öskå Thanks, AxesOrigin works! I am on V8 at work and on V9 at home :) – Funzies Nov 21 '13 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 '13 at 16:57
up vote 1 down vote accepted

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};
styles = Thread[{Thick, {Red, Brown}}];
legends = Table["function " <> ToString[i], {i, 2}];
Plot[functions, {x, 0, 1}, PlotStyle -> styles, 
   PlotLegends -> legends, AxesOrigin -> {0, 0.6}]

enter image description here

share|improve this answer
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? – Funzies Nov 21 '13 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}]]? – Hector Nov 22 '13 at 13:20

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.