TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am using legend columns=-1 to make a horizontal legend. However, the distance between the individual legend entries is too small for my taste. Is there a straightforward way to increase the horizontal spacing between individual legend entries?

share|improve this question
up vote 37 down vote accepted

The legend is a TikZ matrix, so you can use the styles that apply to general matrices to influence the appearance.

In the legend matrix, the sample image and the entry text each occupy their own cell, so we have to increase the spacing for every second cell. For this, we can use the every even column style: By setting the column sep value of the matrix to a larger value for every second column, the horizontal spacing between the legend entries is increased without changing the distance between the image and the text.

\begin{axis}[legend columns=-1,
legend entries={Long plot title, B, C},
legend style={/tikz/every even column/.append style={column sep=0.5cm}}]




Spacing between columns in pgfplots legend

To adjust the spacing between rows of entries, we don't need to jump through the every even column/.append style hoop. Instead, we can just say legend style={row sep=0.5cm}.

share|improve this answer
Works nicely, thanks! – Jannik Jochem May 13 '11 at 15:55

Your Answer


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.