Error: addplot graphics in combination with legend
Brought to you by:
cfeuersaenger,
ludewich
Hi,
when I use addplot graphics in combination with a legend (via \legend or \addlegendentry) I get the following error:
ERROR: Package pgfplots Error: Error using 'plot graphics': I encountered more than
--- TeX said ---
two coordinates!? I expected only the lower left and upper right corners!.
Hope, I am not doing something wrong or stupid, example together with the used graphic attached.
Best,
Christoph
\documentclass{article}
\usepackage{pgf}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}
\addplot graphics[xmin=0, xmax=5, ymin=0, ymax=5] {pic.png};
\addplot coordinates {(1,1) (2,2) (3,3) (4,4)};
%works if this is commented out
\addlegendentry{coordinates};
\end{axis}
\end{tikzpicture}
\end{document}
pic used in the example
Thank you for reporting this issue! It is indeed a bug; the package tries to load the image for the legend as well.
For the moment, you can use
\addplot+[every legend image post/.append style={sharp plot}]
.....
which tells the legend to use standard line plot. You may want to append any style options like "red" or so to adjust the legend image.
I will fix the problem for the next stable release and apologize for the inconvenience.
best regards
Christian
Hi Christoph,
I have now fixed the issue. The legend will now use the correct plot handler and the correct plot mark, without the clumsy interface I proposed as work around.
The bugfix will be part of the next stable (or, probably earlier, available as unstable TDS .zip file on the web page).
Thanks again for the bug report.
Best regards
Christian