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 want to reference a plot in the legend. The problem is, that the little legend image from the blue plot is shown distorted in the legend.

Here a minimal example:

    \addplot[color=red] coordinates {(1, 1) (2, 200)};
    \addlegendentry{plot 1 (\ref{pgfplots:plot2} xy added)}

    \addplot[color=blue, mark=x, forget plot] coordinates {(2, 200) (2.5, 100) (3, 50)};

    \addplot[color=red, forget plot] coordinates {(3, 50) (4, 100)};
Here the legend image \ref{pgfplots:plot2} is displayed correctly.

How is it possible to fix this? Thanks for your time.

share|improve this question
I suspect this is a bug in pgfplots: consider reporting it via the e-mail address given in the package documentation. – Joseph Wright Jul 21 '12 at 6:31

It is a bug in pgfplots 1.5.1 (the current stable).

I will take care of it (the \tikzifinpicture macro shipped with tikz needs to be fixed).

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.