I am not sure where the problem is, but using gnuplot as per the MWE below does not know about the -output-directory= option as I get
Package pgfplots Error: sorry, plot file{TeX-SE_contourtmp0.table} could not be opened.
So if you save the MWE as TeX-SE.tex, the following fails with the above error message:
mkdir tempfiles
pdflatex -shell-escape -output-directory=tempfiles TeX-SE.tex
but the following works fine
pdflatex -shell-escape TeX-SE.tex
Code
\documentclass[border=2pt]{standalone}
\usepackage{pgfplots}
\begin{document}
\pgfmathdeclarefunction{FunctionE}{2}{%
\pgfmathparse{exp(-#1^2) * sin(deg(#2))}%
}
%% Following based on code from http://tex.stackexchange.com/questions/87674/how-to-coherently-combine-3d-and-contour-plots-with-pgfplots
\begin{tikzpicture}
\begin{axis}[
domain=-2:2,
domain y=0:2*pi,
xlabel=$x$,
ylabel=$y$,
zlabel=$z$,
]
\addplot3[%
contour gnuplot={
output point meta=rawz,
number=10,
labels=false,
},
samples=41,
z filter/.code=\def\pgfmathresult{-1.6},
]
{FunctionE(x,y)};
\addplot3[surf,samples=25] {FunctionE(x,y)};
\end{axis}
\end{tikzpicture}
\end{document}
tempfilesfolder. So maybe it helps -- as you guess this is untested -- when you add\pgfplotsset{prefix=tempfiles/}to the preamble, to redirect the gnuplot output to that folder, too. – Stefan Pinnow Mar 13 '17 at 12:34TeX-SE_contourtmp0.datandTeX-SE_contourtmp0.scriptfiles do get written to thetempfiles/directory, but theTeX-SE_contourtmp0.tableis not generated. – Peter Grill Mar 13 '17 at 12:44gnuplotbutcontour gnuplot... Ok, let's see, if someone else has a solution. Otherwise I will ask Christian (Feuersänger) -- the author of PGFPlots -- for a possible solution. – Stefan Pinnow Mar 13 '17 at 12:55cmd= {cd tempfiles & gnuplot \"\script\"}to yourcontour gnuplotoptions (if you are on linux replace the & with whatever is used there to combine commands). You could also try to find a working solution with thefileand theprefixkey, but imho they and--output-directoryconfuse each other, and like @DavidCarlisle I think that the best is not to use--output-directory. – Ulrike Fischer Mar 13 '17 at 13:37