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've been using the shiny new legends in V9 for my plots. However, I usually increase the Frame/Axis Thickness and the plot Thickness and I would like the thickness of the legend line to match. There is a related question (Legend of a plot: how to increase the size of the line/marker?) asked about using the previous PlotLegends package.

See this simple example, modified from the documentation:

Plot[{Sin[x], Cos[x]}, {x, 0, 2 \[Pi]}, 
  PlotLegends -> Automatic, 
  PlotStyle -> Thickness[0.005], 
  AxesStyle -> Thickness[0.005]]

Mathematica graphics

I've tried the obvious modification of the LineLegend LabelStyle, however, this just appears to modify the text and has no effect here:

Plot[{Sin[x], Cos[x]}, {x, 0, 2 \[Pi]}, 
  PlotLegends -> LineLegend[Automatic, LabelStyle -> Thickness[0.5]], 
  PlotStyle -> Thickness[0.005], 
  AxesStyle -> Thickness[0.005]]

Mathematica graphics

I found that I could set Joined -> False and use a thicker line as a LegendMarker but it is never as long as the normal legend line no matter how long you make the line... (also note that to get a comparable thickness it has to be set two orders of magnitude higher)

Plot[{Sin[x], Cos[x]}, {x, 0, 2 \[Pi]}, 
 PlotLegends -> 
  LineLegend[Automatic, Joined -> False, 
   LabelStyle -> Directive[FontFamily -> "Helvetica", Medium], 
   LegendMarkers -> 
    Graphics[{Thickness[0.5], Line[{{-2, 0}, {2, 0}}]}]], 
 PlotStyle -> Thickness[0.005], AxesStyle -> Thickness[0.005]]

Mathematica graphics

now make the line really long (no change):

Plot[{Sin[x], Cos[x]}, {x, 0, 2 \[Pi]}, 
 PlotLegends -> 
  LineLegend[Automatic, Joined -> False, 
   LabelStyle -> Directive[FontFamily -> "Helvetica", Medium], 
   LegendMarkers -> 
    Graphics[{Thickness[0.5], Line[{{-100, 0}, {100, 0}}]}]], 
 PlotStyle -> Thickness[0.005], AxesStyle -> Thickness[0.005]]

Mathematica graphics

I've tried to look at the InputForm for the plots and for just a LineLegend but I can't figure out what exactly I need to replace to fix this.

share|improve this question
    
Note, the boxed 1 and 2 are placeholders that can be edited. Personally, I prefer "Expressions" to Automatic as it will display the equations used, for function plots, only, of course. –  rcollyer Mar 15 '13 at 3:02
    
I think you're looking for LegendMarkerSize. See also: mathematica.stackexchange.com/q/19283/8 –  Verbeia Mar 15 '13 at 4:08
add comment

2 Answers

up vote 5 down vote accepted

I find it useful to stick with AbsoluteThickness (and related) when using PlotLegends.

Plot[{Sin[x], Cos[x]}, {x, 0, 2 \[Pi]}, PlotLegends -> Automatic, 
  PlotStyle -> AbsoluteThickness[2], AxesStyle -> AbsoluteThickness[2]]

enter image description here

share|improve this answer
add comment

If you remove Joined->False it seems that you can get a better length for the given line thickness:

Plot[{Sin[x], Cos[x]}, {x, 0, 2 \[Pi]}, 
PlotLegends -> 
LineLegend[Automatic, 
LabelStyle -> Directive[FontFamily -> "Helvetica", Medium], 
LegendMarkers -> 
Graphics[{Thickness[0.2], Line[{{-10, 0}, {10, 0}}]}]], 
PlotStyle -> Thickness[0.005], AxesStyle -> Thickness[0.005]]

thicker and longer lines

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.