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.

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 the awesome pgfplots package to draw some plots. I usually use \addlegendentry and get a nice default legend box. There are some options for legend box placement and layout (e.g. number of columns).

For some plots I would like to add a title inside the legend box.

Could not find the something about this in the manual. Does anyone know what is the way to customize the legend box?

share|improve this question
up vote 15 down vote accepted

You could perhaps use the \addlegendimage command, as in this discussion from the pgfplots-features mailing list.

An example, with a small \hspace hack to place the title more centered in the legend box:

\begin{axis}[legend pos=south east]
   \addlegendimage{empty legend}
   \addplot {sqrt(x)}; 
   \addplot {ln(x)}; 

   \addlegendentry{\hspace{-.6cm}\textbf{A title}}

enter image description here

share|improve this answer

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.