0

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}
Peter Grill
  • 223,288
  • I assume that is because gnuplot doesn't know that it should also output to the tempfiles folder. 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:34
  • @StefanPinnow: Nope, that does not seem to do it. It seems that the TeX-SE_contourtmp0.dat and TeX-SE_contourtmp0.script files do get written to the tempfiles/ directory, but the TeX-SE_contourtmp0.table is not generated. – Peter Grill Mar 13 '17 at 12:44
  • Oh yeah, forgot that it was not simply gnuplot but contour 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:55
  • http://tex.stackexchange.com/questions/206695/latexmk-outdir-with-include#comment481933_206695 – David Carlisle Mar 13 '17 at 12:56
  • @DavidCarlisle: Had not seen that comment before. Am hoping htat mine is the 1/1000. I did not know that you could link to specfic comments like that. How do you get the url for it? – Peter Grill Mar 13 '17 at 13:11
  • the "time" that appears after a comment is a URL to the comment so for example your comment above currently says "1 min ago" which links to http://tex.stackexchange.com/questions/358224/using-output-dir-with-gnuplot-fails-to-find-table-file?noredirect=1#comment882377_358224 – David Carlisle Mar 13 '17 at 13:14
  • You could try to add cmd= {cd tempfiles & gnuplot \"\script\"} to your contour gnuplot options (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 the file and the prefix key, but imho they and --output-directory confuse each other, and like @DavidCarlisle I think that the best is not to use --output-directory. – Ulrike Fischer Mar 13 '17 at 13:37
  • @UlrikeFischer: That works great. Thanks. Please add an answer. – Peter Grill Mar 13 '17 at 23:01

1 Answers1

1

You could try to add

  cmd= {cd tempfiles & gnuplot \"\script\"} 

to your contour gnuplot options (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 the file and the prefix key, but imho they and --output-directory confuse each other.

Like David Carlisle in his comment I think that the best is not to use --output-directory.

Ulrike Fischer
  • 327,261