Using pgfplot externalize with .eps output

I'm trying use to use pgfplot's externalization feature b/c I've got many large plots that I don't want to regenerate every time I typeset my thesis. Other components of my thesis require compile via latex > ps > pdf (i.e. "latex" followed by "dvips" followed by "ps2pdf"), so I'm trying to stick with that. I'm having trouble getting the externalization to work, unfortunately. Here is my minimum example, which I have produced by following the instructions in the pgfplots manual for getting .eps output (pg 240).

\documentclass{article}
\usepackage{pgfplots}
\usetikzlibrary{pgfplots.groupplots}
\usepgfplotslibrary{external}
\tikzexternalize[shell escape=-enable-write18]
\tikzset{external/system call={latex \tikzexternalcheckshellescape -halt-on-error -interaction=batchmode -jobname "\image" "\texsource" & dvips -o "\image".ps "\image".dvi}}

\begin{document}

\begin{tikzpicture}
\begin{axis}[xlabel=x,ylabel=y]
\end{axis}
\end{tikzpicture}

\end{document}


When I do the compile, the external .dvi and .ps files for the figure are successfully generated and there are no errors, but the figure is absent from the actual compiled document .pdf. The pgfplots manual suggested I would get .eps output, but this doesn't happen (perhaps this is the trouble?). Anyone have any tips for what I'm doing wrong?

-
Wild guess here, but I've noticed some funny things in pgfplots go away with a second pass. I haven't verified that from the documentation, but maybe it's needed. Can you change the system call to run latex twice? –  Matthew Leingang Dec 16 '10 at 15:31
At your suggestion, I tried using the same call to latex twice in a row and it didn't fix the problem. –  Matt Williams Dec 16 '10 at 16:02
Well, it was worth a shot... –  Matthew Leingang Dec 16 '10 at 16:18
Here's one solution that probably wasn't as intended by the pgfplots people (so if anyone has other thoughts, I'd still really love to hear them)... If you add & perl ps2eps.pl -f "\image".ps to the end of the system call, assuming you have perl and ps2eps installed (with ps2eps.pl in your current directory in this example), it will compile as desired with no errors. –  Matt Williams Dec 16 '10 at 17:32
This works for me with TeX Live 2010 when I remove the line \tikzexternalize[shell escape=-enable-write18]. Which TeX system do you use, and can you post your log? –  Joseph Wright Dec 16 '10 at 21:01

It looks like you made two typos in the \tikzset line; changing it to:

\tikzset{external/system call={latex \tikzexternalcheckshellescape -halt-on-error -interaction=batchmode -jobname "\image" "\texsource" && dvips -o "\image".eps "\image".dvi}}


will make the shell command generate an .eps file from each .dvi file after running the latex command to create that .dvi file. (I replaced a .ps in your file with a .eps, and a & with a &&. Interestingly, the & seemed to work in MiKTeX to invoke latex asynchronously; I wonder why it did that? I don't think cmd.exe supports that, though it does support &&.)

But unfortunately none of that seems to help: though I end up with a postscript file for the whole document that includes the contents of the .eps, it doesn't seem to display any of it, though the .eps file renders fine on its own, and I don't get any error messages about it either :-(.

-

Usually people forget to properly activate unrestricted shell escape:

latex -shell-escape foo.tex

-