I try to create Tikz figure with several pgfplots
subplots. I want to have one legend for them since they all have the same curves. I found out from this question that i can label and than reference each curve. I used that to create simple legend at the bottom of the subplots. And it looked just fine when I tried it as a separate file. Then I put it in my thesis where I use the Tikz external
library which solves the TeX memory problem I encountered before because I have many plots. The problem that occurs can be reproduced by this MWE:
\documentclass{article}
\usepackage{pgfplots}
\usetikzlibrary{external}
\tikzexternalize
\begin{document}
\begin{tikzpicture}
\begin{axis}
\addplot coordinates { (0,0) (1,1) };\label{plot:p1}
\end{axis}
\node (A) at (1,-1) {\ref{plot:p1} Plot 1};
\end{tikzpicture}
\end{document}
which produces:
instead of:
(I'm using just one plot here instead of subplots for simplicity). Notice the question marks for the missing reference in the first image. Of course, if I comment out the 4th line (don't use externalize) the reference turns out just fine (the second image). So I wonder:
How can I get the reference and still use externalize?
P.S.: TexLive 2011 on Ubuntu 11.10