# TikZ & External: figure re-created for no apparent reason

I'm having an issue where only one out of multiple figures is recreated despite the use of the tikz/external library. I've created a MWE which shows the same effect with only two figures.

Below is my main file which is compiled with pdflatex -shell-escape file.

\documentclass{article}

\usepackage{tikz,pgfplots,tikzscale}
\usetikzlibrary{external}
\tikzexternalize[prefix=figures/]
\graphicspath{ {./figures/}{./figures-tikz/} }

\newcommand{\figFilename}{}

\begin{document}
\begin{figure}[t!]
\renewcommand{\figFilename}{scalability-plot-all-sbb-2-optima}
\centering
\tikzpicturedependsonfile{\figFilename.tikz}
\tikzsetnextfilename{\figFilename}
\includegraphics[width=\textwidth,axisratio=1]{\figFilename.tikz}
\caption{Scalability plot for dDE, MPC, dDE$^-$ and a hill climber on the Scalable-Building-Block problem.}
\label{fig:\figFilename}
\end{figure}

\begin{figure}[t!]
\renewcommand{\figFilename}{scalability-plot-all-sbb-2-optima-log-y}
\centering
\tikzpicturedependsonfile{\figFilename.tikz}
\tikzsetnextfilename{\figFilename}
\includegraphics[width=\textwidth,axisratio=1]{\figFilename.tikz}
\caption{Same as in Figure~\ref{fig:scalability-plot-all-sbb-2-optima}, but y axis is in logscale.}
\label{fig:\figFilename}
\end{figure}
\end{document}

The first figure is re-created every time I run pdflatex. I tried changing the ordering of the two, but it does not make a difference --- the figure with the filename scalability-plot-all-sbb-2-optima is the one that's always re-created even though the other figure is identical but with a semilogyaxis instead. The TikZ files for both are merely five addplot commands which load data from five different .dat files. Showing everything here would take up a lot of space, so here's a link to the whole directory structure, including the .tex, .tikz and .dat files.

I've found that if I keep only one addplot, the figure is not re-created. I was wondering whether this is a bug, whether LaTeX is confused by my directory structure, or whether it's simply a mistake on my part.

-
–  Papiro Jul 14 '13 at 16:53
Is this really a MWE, do you need all those packages to reproduce the problem? –  Miguel de Val-Borro Jul 14 '13 at 18:35
I left it this way in case there was a package incompatibility issue. –  sudosensei Jul 14 '13 at 19:29