I am using the following TeX code (minimal example), which compiles fine, when running pdflatex then run make -f filename.makefile and repeat the procedure a second time to also include the referenced legend:
\documentclass{article}
\usepackage{pgfplots}
\usepgfplotslibrary{external}
\usepackage{tikz}
\pgfplotsset{
/tikz/external/mode=list and make
}
\tikzexternalize
\begin{document}
\begin{figure}
\ref{leg}
\begin{tikzpicture}
\begin{axis}[legend to name=leg]
\addplot {x};
\addlegendentry{$x=0,1$};
\end{axis}
\end{tikzpicture}%
\end{figure}
\end{document}
As I need to submit the files to a journal I can not use the pgfplots package and would like to use the tikzexternal.sty package instead. In order to do so I tried to replace lines 3-9 with \usepackage{tikzexternal} and put the tikzexternal.sty file into the directory. However, this does not seem to be compatible with the legend to name feature.