# How to change line lengths in LineLegend

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]


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.

• Is LegendMarkerSize what you're looking for? Please check the examples for this option on the LineLegend documentation page. Mar 26, 2015 at 18:09

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];