How can I shorten the lengths of the LineLegend[] lines in the following plot?

Is there a way to control line spacing as well?

styles = {Orange, Blue};
legend = LineLegend[styles, {"f", "g"}];
plot = Plot[{-Sin[x], Cos[2 x]}, {x, -Pi/2, Pi/2}, PlotStyle -> styles,
  Epilog -> Inset[legend, Scaled[{1, 1}], Scaled[{1, 1}]], ImageSize -> 72*3.375/2]

Plot using LineLegend

I am generating a figure for a publication where I want to control image size, font size, line widths, etc. in absolute terms, e.g., printers points.

  • 2
    $\begingroup$ Is LegendMarkerSize what you're looking for? Please check the examples for this option on the LineLegend documentation page. $\endgroup$
    – Szabolcs
    Commented Mar 26, 2015 at 18:09

1 Answer 1


First question answered, here we go with LegendMarkerSize:

legend = LineLegend[styles, {"f", "g"}, LegendMarkerSize -> 5];

Second question answered: Customize a Grid for the legend using the Spacing option and use it in LegendLayout. Play around with Spacing values for horizontal and vertical adjustments. Here we go

table[pairs_] := Grid[pairs, Spacings -> {.5, 0}];
legend = LineLegend[styles, {"f", "g"}, LegendMarkerSize -> 5, 
   LegendLayout -> table];

..good luck with your publication :) ...some royalties on your publication, please, hi,hi,hi


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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