# TikZ externalize option causes error in compilation

As the title says, the externalize option causes some strange errors I can't figure out of. It works for some figures (e.g. figures for which the code I've found in the pgfplots manual), but for some other figures which are generated with i.e. matlab2tikz, I get some strange errors if the externalize option is activated.

E.g. if my document looks like

\documentclass[12pt]{standalone}

\usepackage{pgfplots}
\usetikzlibrary{external}
\tikzexternalize[prefix=figures/]

\begin{document}

\begin{tikzpicture}
\pgfplotsset{every axis/.append style={line width=0.5pt}}

\begin{axis}[%
view={0}{90},
width=4in,
height=3in,
scale only axis,
xmin=0, xmax=6.28318530717959,
ymin=-0.999874127673875, ymax=0.999874127673875,
outer axis line style={line width=0.8pt},
grid style={densely dashed}]
color=blue,
solid
]
coordinates{
(0,0)(0.0634665182543393,0.0634239196565645)(0.126933036508679,0.126592453573749)(0.190399554763018,0.18925124436041)(0.253866073017357,0.251147987181079)(0.317332591271696,0.312033445698487)(0.380799109526036,0.371662455660328)(0.444265627780375,0.429794912089172)(0.507732146034714,0.486196736100469)(0.571198664289053,0.540640817455598)(0.634665182543393,0.59290792905464)(0.698131700797732,0.642787609686539)(0.761598219052071,0.690079011482112)(0.82506473730641,0.734591708657533)(0.88853125556075,0.776146464291757)(0.951997773815089,0.814575952050336)(1.01546429206943,0.849725429949514)(1.07893081032377,0.881453363447582)(1.14239732857811,0.909631995354518)(1.20586384683245,0.934147860265107)(1.26933036508679,0.954902241444074)(1.33279688334112,0.971811568323542)(1.39626340159546,0.984807753012208)(1.4597299198498,0.993838464461254)(1.52319643810414,0.998867339183008)(1.58666295635848,0.999874127673875)(1.65012947461282,0.996854775951942)(1.71359599286716,0.989821441880933)(1.7770625111215,0.978802446214779)(1.84052902937584,0.963842158559942)(1.90399554763018,0.945000818714669)(1.96746206588452,0.922354294104581)(2.03092858413886,0.895993774291336)(2.0943951023932,0.866025403784439)(2.15786162064753,0.832569854634771)(2.22132813890187,0.795761840530832)(2.28479465715621,0.755749574354258)(2.34826117541055,0.712694171378863)(2.41172769366489,0.666769000516292)(2.47519421191923,0.618158986220606)(2.53866073017357,0.567059863862771)(2.60212724842791,0.513677391573407)(2.66559376668225,0.458226521727411)(2.72906028493659,0.400930535406614)(2.79252680319093,0.342020143325669)(2.85599332144527,0.28173255684143)(2.91945983969961,0.220310532786541)(2.98292635795395,0.15800139597335)(3.04639287620828,0.0950560433041829)(3.10985939446262,0.0317279334980681)(3.17332591271696,-0.0317279334980679)(3.2367924309713,-0.0950560433041826)(3.30025894922564,-0.15800139597335)(3.36372546747998,-0.220310532786541)(3.42719198573432,-0.281732556841429)(3.49065850398866,-0.342020143325669)(3.554125022243,-0.400930535406613)(3.61759154049734,-0.45822652172741)(3.68105805875168,-0.513677391573406)(3.74452457700602,-0.567059863862771)(3.80799109526036,-0.618158986220605)(3.87145761351469,-0.666769000516292)(3.93492413176903,-0.712694171378863)(3.99839065002337,-0.755749574354258)(4.06185716827771,-0.795761840530832)(4.12532368653205,-0.832569854634771)(4.18879020478639,-0.866025403784438)(4.25225672304073,-0.895993774291336)(4.31572324129507,-0.922354294104581)(4.37918975954941,-0.945000818714668)(4.44265627780375,-0.963842158559942)(4.50612279605809,-0.978802446214779)(4.56958931431243,-0.989821441880933)(4.63305583256677,-0.996854775951942)(4.69652235082111,-0.999874127673875)(4.75998886907544,-0.998867339183008)(4.82345538732978,-0.993838464461254)(4.88692190558412,-0.984807753012208)(4.95038842383846,-0.971811568323542)(5.0138549420928,-0.954902241444074)(5.07732146034714,-0.934147860265107)(5.14078797860148,-0.909631995354519)(5.20425449685582,-0.881453363447582)(5.26772101511016,-0.849725429949514)(5.3311875333645,-0.814575952050336)(5.39465405161884,-0.776146464291757)(5.45812056987318,-0.734591708657534)(5.52158708812751,-0.690079011482113)(5.58505360638185,-0.64278760968654)(5.64852012463619,-0.59290792905464)(5.71198664289053,-0.540640817455597)(5.77545316114487,-0.486196736100469)(5.83891967939921,-0.429794912089172)(5.90238619765355,-0.371662455660328)(5.96585271590789,-0.312033445698487)(6.02931923416223,-0.251147987181079)(6.09278575241657,-0.189251244360411)(6.15625227067091,-0.12659245357375)(6.21971878892525,-0.0634239196565654)(6.28318530717959,-2.44929359829471e-16)
};
\end{axis}
\end{tikzpicture}%

\end{document}


I get errors that suggest I've forgotten a } somewhere.

If I, however, comment out the two lines for externalizing, it works just fine, so nothing wrong with the code for the figure.

I've never experienced any problems with this until recently, but I really can't tell what has triggered it. I've installed the latest builds (unstable) of both pgfplots and tikz, but this hasn't caused any problems before. Only recent changes are that I tried to install the MinionPro fonts, but I can't see how this is related?

The log for the case I experience a compilation error can be found here

I also tried installing the pretest of the new TL last night, but still the same. Any suggestions?

-
This works fine for me if I either create the subfolder figures manually, or remove the prefix=figures/ option. –  Jake Jun 9 '12 at 16:22
Here, your document works fine. Tested with TeXLive2011 and pgf 2.10 and with pretest TeXLive2012 and CVS-pgf. –  Paul Gaborit Jun 9 '12 at 16:24
That's strange. Maybe I have to try to remove all the files that are related to the MinioPro fonts and try again. Really annoying though, as I can't see why that should be related. I can also add that with some other plots, it works just fine (i.e. if I use code from plots in the pgfplots manual, it works fine with and without externalize activated. But with data generated in Matlab, like in the MWE, I experience the error). –  militiaOfDeath Jun 9 '12 at 16:26
I tried to move the texmf-local dir to somewhere where mktexlsr can't find it, and then it worked fine with and without externalize activated. After moving it back c:\texlive\ the error occurs again. So it has to be related to either CVS-pgf, or CVS-pgfplots, or the MinionPro fonts. Those are the only things I've added in the local texmf dir. –  militiaOfDeath Jun 9 '12 at 17:16
My guess is that you have an instable CVS version. Did you update to the most recent version? I know one TikZ CVS revision which would not work with your image (because of the empty line in the tikzpicture). This has been fixed soon after that revision; but maybe you have not pulled that update. Note that this would purely affect pgf CVS. Anyway; my pgf CVS revision works fine with your image. –  Christian Feuersänger Jun 9 '12 at 19:23