Sign up ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I am fairly new to using pgfplots and have been combing the manual for a couple hours now and I can't find an elegant solution to my problem. I would like to have two columns of legend entries and then one "label" underneath them all and centered. I managed to get it by playing with the [text width= ] settings, but I was wondering if there was a better way. MWE:

                every axis/.append style={thick}}

        legend pos=north west,
        legend columns=2,
        scaled y ticks = false,
        yticklabel={\$ \pgfmathprintnumber{\tick} },
        ytick={-5500, 0, 5000, 10000, 15000},
    \addplot[mark=none, color=red, domain=0:5.5] {900*x -5200};
    \addplot[mark=none, color=green, domain=0:5.5] {1900*x -5200};
    \addplot[mark=none, color=blue, domain=0:5.5] {2900*x -5200};
    \addplot[mark=none, color=orange, domain=0:5.5] {3900*x -5200};
    \addlegendimage{empty legend}
    \addlegendentry[text width=30pt]{Drinks/Day}
share|improve this question
btw, is there a less annoying way to insert code than to go add 4 spaces to each line? –  JayCle Apr 26 '14 at 14:37
If you are using Emacs with AUCTeX, you can hit tab and it will indent the line to the appropriate level. I imagine other editors do the same (at least that would be nice). –  dustin Apr 26 '14 at 14:40
@JayCle: A tip: If you indent lines by 4 spaces, they'll be marked as a code sample. You can also highlight the code and click the "code" button (with "{}" on it). Or just highlight and press "CTRL-K"... –  Christian Hupfer Apr 26 '14 at 14:40
@ChristianHupfer he meant on the forum. I thought in his editor to achieve the indentation. My mistake. –  dustin Apr 26 '14 at 14:42
@dustin: No problem at all ;-) –  Christian Hupfer Apr 26 '14 at 14:44

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.