2

Possible Duplicate:
pgfplots: externalization and legend referencing

I am trying to implement references to plots using there legend image with pgfplots. I use the example on page 164 of the manual:

\documentclass{article}

% This part of preamble works
\usepackage{pgfplots}
\usepackage{pgfplotstable}
\pgfplotsset{width=7cm,compat=newest}  

% This part of preamble generates an error (see below)
\usetikzlibrary{external}
\tikzexternalize[prefix=tikz/,shell escape=-enable-write18]

\begin{document}
\begin{tikzpicture}[baseline]
  \begin{axis}
    \addplot+[only marks,
    samples=15,
    error bars/y dir=both,
    error bars/y fixed=2.5]
    {3*x+2.5*rand};
        \label{pgfplots:label1}
    \addplot+[mark=none] {3*x};
        \label{pgfplots:label2}
    \addplot {4*cos(deg(x))};
        \label{pgfplots:label3}
  \end{axis}
\end{tikzpicture}

The picture shows the estimations \ref{pgfplots:label1} which are subjected to noise.
It appears the model \ref{pgfplots:label2} fits the data appropriately.
Finally, \ref{pgfplots:label3} is only here to get three examples.

\end{document}

When I want to use externalization, the second block of the preamble generates an error or simply non working references (??, on a more complicated example).

The error message is not explicit but I noticed this in the log file:

! Undefined control sequence.
l.1 ...[/pgfplots/every crossref picture]\pgfplots
                                              @draw@image
l.32 blablabla \ref{pgfplots:label1}

Do you know what I am doing wrong?

M. Toya
  • 3,227

0 Answers0