2
$\begingroup$

I would like to gain control over the distance between the rows in PlotLegends to make more compact legends. I am using Mathematica 10. This is my code:

ListPlot[{Table[x, {x, 0, 10}],Table[0.5*x, {x, 0, 10}],Table[2 - 0.5*x, {x, 0, 10}],Table[4 - 0.1*x, {x, 0, 10}]},Joined -> True,PlotStyle -> {{Red, AbsoluteThickness[4], Dashed}, {Red,AbsoluteThickness[4]},{Blue,AbsoluteThickness[4],Dashed}, {Blue, AbsoluteThickness[4]}},FrameLabel -> {"space [microns]", "strength [GPa]"},PlotRange -> {{0, 12}, {0, 6}}, PlotRangePadding -> Scaled[.05],GridLines -> {{0}, None},PlotLegends -> Placed[LineLegend[{Style["one", FontSize -> 20],Style["two", FontSize -> 20],Style["three", FontSize -> 20],Style["four", FontSize -> 20]},
LegendFunction -> (Framed[#, Background -> LightGray,FrameStyle -> Directive[Black, Thick]] &),LegendMargins -> 0], Scaled[{0.6, 0.4}]]]
$\endgroup$
  • $\begingroup$ add the option "Spacings" -> .5 to LineLegend? $\endgroup$ – kglr Mar 9 '18 at 15:06
  • $\begingroup$ this is what I was missing. Thanks! $\endgroup$ – Luigi Mar 9 '18 at 15:17
  • $\begingroup$ Luigi, posted the comment as an answer. $\endgroup$ – kglr Mar 9 '18 at 15:44
1
$\begingroup$

Using the option

"Spacings" -> .5

in LineLegend gives

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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