Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I am currently trying to get to graph with several functions as below. My problem is that I cannot change the font size in the legend (authomatically generated numbers by "Table" function). This code below is the best what I can get. Does anyone know how to insure that also automatically generated numbers have font size of 16 (or any).

Thanks!

<<PlotLegends`
Plot[
  Evaluate[(g (-1+q)^2 (a+b+g (1-q ) s)^2)/((a+b+g-g p q)^3) 
             /.{q->4/5,p->1/4,a->0.1,g->500,s->Range[0.1,3,0.4]}
  ],
  {b,0,100},
  AxesLabel->{b,F},
  PlotLabel->Style["q = 4/5, p = 1/4",FontSize->14],
  PlotStyle->Directive[Thick],
  PlotLegend->Table[Row[{Style["s = ",Bold,Italic,FontSize-> 16],i}],{i,0.1,3,0.4}],
  LabelStyle->Directive[Italic,FontFamily->"Helvetica",FontSize->12],
  LegendPosition->{0.5,-0.8}
]
share|improve this question
    
If you have version 9 you should probably switch to the much better, built-in PlotLegends functionality. –  Sjoerd C. de Vries May 7 '13 at 18:12
    
Thank you for editing my code, I failed to do it properly... –  Cactusenok May 7 '13 at 18:13
    
No, unfortunately I have Version 7... I saw that in 9 it is much more efficient... –  Cactusenok May 7 '13 at 18:14
add comment

2 Answers

up vote 1 down vote accepted

You could use Style[StringForm["s = ``", i], Bold, Italic, 16] to combine number and string (and quite a bit of PlotLegends parameter fumbling):

<< PlotLegends`
Plot[Evaluate[(g (-1 + q)^2 (a + b + g (1 - q) s)^2)/((a + b + g - g p q)^3) 
               /. {q -> 4/5, p -> 1/4, a -> 0.1, g -> 500, s -> Range[0.1, 3, 0.4]}
     ], 
 {b, 0, 100}, 
 AxesLabel -> {b, F}, 
 PlotLabel -> Style["q = 4/5, p = 1/4", FontSize -> 14], 
 PlotStyle -> Directive[Thick], 
 PlotLegend -> Table[Style[StringForm["s = ``", i], Bold, Italic, 16], {i, 0.1, 3, 0.4}],
 LabelStyle -> Directive[Italic, FontFamily -> "Helvetica", FontSize -> 12],
 LegendPosition -> {0.85, -0.55}, 
 LegendSize -> {0.6, 1.}, 
 ImageSize -> 600
]

enter image description here

share|improve this answer
    
Many thanks to both of you for your answers!! Both are extremely helpful. I will see which I will apply at the end as in fact I have several graphs (using "GraphicsGrid") but the same legend for all. But the hints you gave me provide already a lot of flexibility. Thanks again!! –  Cactusenok May 7 '13 at 22:07
    
@Cactusenok If you like it an upvote and/or accept would be nice ;-) –  Sjoerd C. de Vries May 7 '13 at 22:11
add comment

In your legend, you can replace the line

Row[{Style["s = ",Bold,Italic,FontSize-> 16],i}]

by this:

 Row[{"s = ", i}, BaseStyle -> {Bold, Italic, FontSize -> 16}]

Here, I just used an option for Row to specify the style, because both elements of Row are intended to have the same style. Your statement had Style wrapping only the first element of the Row.

However, the formatting of PlotLegends is so incredibly bad that the newly increased size of the legend gets cut off.

Therefore, I would suggest instead to use my autoLegend function: copy the first code block in this answer and do this:

p = Plot[Evaluate[(g (-1 + q)^2 (a + b + g (1 - q) s)^2)/((a + b + g -
           g p q)^3) /. {q -> 4/5, p -> 1/4, a -> 0.1, g -> 500, 
      s -> Range[0.1, 3, 0.4]}], {b, 0, 100}, AxesLabel -> {b, F}, 
   PlotLabel -> Style["q = 4/5, p = 1/4", FontSize -> 14], 
   PlotStyle -> Directive[Thick]];

autoLegend[p, 
 Table[Row[{"s = ", i}, 
   BaseStyle -> {Bold, Italic, FontSize -> 16}], {i, 0.1, 3, 0.4}]]

autolegend

For more instructions on how to change the placement and format of the legend, see the linked post.

share|improve this answer
add comment

Your Answer

 
discard

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.