The following code is from the "gallery of examples in the manual - PGFPlots".

        title={$x \exp(-x^2-y^2)$},
        domain=-2:2,enlarge x limits,
   \addplot3[contour gnuplot={number=14},thick]

Unfortunately the code does not work and I get the following error message:

! Package pgfplots Error: sorry, plot file{example_175_contourtmp0.table} could
 not be opened.

See the pgfplots package documentation for explanation.
Type  H <return>  for immediate help.

l.17           {exp(0-x^2-y^2)*x};

! Emergency stop.

l.17           {exp(0-x^2-y^2)*x};

End of file on the terminal!

I have no idea what could be the problem. It would be great if anbody can offer a solution.

  • 3
    The error message of pgfplots is quite misleading, I fear. It should have been "I was unable to read the output of gnuplot". Problems can be: there is no gnuplot on the system or, (b) gnuplot could not be executed (see the answer of @aeronotauto). The command contour gnuplot is supposed to make a system call (which needs -shell-escape) in order to invoke gnuplot -- in the hope that this command is available. Does you .log file contain any indication of gnuplot invocations or system calls (try searching for these keywords in your .log file)? May 4, 2015 at 19:16
  • I found runsystem(gnuplot "example_175_contourtmp0.script")...disabled (restricted). in the .log file. Maybe this helps you.
    – user144921
    May 4, 2015 at 19:37
  • Yes: that means that you need to add -shell-escape (or, in some TeX installations on windows, -enable-write18) to you latex invocation. Please refer to the answer of @aeronotauto for details. May 6, 2015 at 15:51
  • I tried -shell-escape, --shell-escape and -enable-write18. But the error still appears.
    – user144921
    May 8, 2015 at 18:19
  • always with ...disabled (restricted) in your log file? May 10, 2015 at 18:35

3 Answers 3


Copy/pasting that code into ShareLaTeX, it compiles with no errors and produces:


What version are you using? And as a random note, compat=newest is generally not recommended.


I was able to reproduce your problem by compiling with only pdflatex filename. Since LaTeX needs to run gnuplot, you have to allow LaTeX to launch third party executables. For this, you need an argument like --shell-escape. Does it work if you compile your example with pdflatex --shell-escape filename?


If you have the files contours_contourtmp0.script and contours_contourtmp0.dat but not contours_contourtmp0.table then chances are, LaTeX was unable to execute gnuplot. You can sort of use the presence of contours_contourtmp0.table to confirm that gnuplot was executed correctly. Also, the example in the user guide will only work if the executable gnuplot exists...I don't know what the Windows version is called, so a Windows user will have to confirm this - that could also be the problem.

  • I use MikTex 2.9 and WinEdt 7.0.
    – user144921
    May 4, 2015 at 17:15
  • @user144921 sorry, i meant version of pgfplots, but i don't really think that's the issue. of course, i must ask the obligatory "are you sure the document you are compiling does not call example_175_contourtmp0.table anywhere?" is that your whole file? i noticed the traceback specifies line 17. May 4, 2015 at 17:19
  • Maybe the problem is that there is no file called "example_175_contourtmp0.table". Only a file named "example_175_contourtmp0" which is a DAT-file is created.
    – user144921
    May 4, 2015 at 17:25
  • And I think the pgfplots-version is "pgfplots 2015/01/31 v1.12".
    – user144921
    May 4, 2015 at 17:27
  • 1
    @user144921 In winedt go to OptionsExecution Modes and in the window that opens choose pdflatex and add --shell-escape like in this picture . Don't forget to press OK button.
    – user11232
    May 5, 2015 at 2:02

Please go to gnuplot homepage Find the download link to SourceForge. Download Windows version EXE file that installs automatically on Windows. It is for all versions of Windows, the same. Save it on your computer.

Run it as administrator (right click run as administrator). When shows installation options do not forget to tick the checkbox for "Add Path to Environment Variables." Let the software does it rather than doing it manually.

Also use its default definition for the terminal.

Allow it to run for the first time when it asks after finishing install by checking the "Run gnuplot" box. Then close it. Close everything and reboot your computer.

Now run your tex editor such as my TexnicCenter as administrator, recompile your tex file and it should eliminate the error. In case add --shell-escape as advised by others. It is not necessary for DVI compile, though; it can creates unresolved warning from gnuplot. In such case use -enable-write18, instead as described in page 37 of "Manual for Package pgfplots" by Dr. Christian Feuersanger.


In 2023 I think the recommended best practice is to use the luatex engine if possible. Then you just need to change contour gnuplot to contour lua and it Just Works without needing to run an external problem.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .