Contour plot error with pgfplot and tikz

I'm trying to plot contour lines of a two variable function. I found this example here:

\begin{tikzpicture}
\begin{axis}[view={0}{90}]
labels over line,number=9}]
{x*y};
\end{axis}
\end{tikzpicture}


But I get the following error:

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

What is going on?

This example invokes the external program gnuplot to compute coordinates.

By default latex doesn't allow to launch such external executables because of potential dangers connected with compiling arbitrary sources that might invoke malicious commands without you noticing.

So you need to explicitly enable external program calls with the -shell-escape command-line option:

pdflatex -shell-escape filename.tex


This is documented pretty well in pgfplots manual (section 4.3.5, rev 1.12.1).

• Could you elaborate a bit on it, e.g. why to do it? – Stephen Dec 21 '15 at 18:48
• Ok, should be better now – filippo Dec 21 '15 at 19:19
• Great, thank you and +1 for the answer! – Stephen Dec 21 '15 at 19:22
• @filippo what if it does not work on my laptop? It seems giving the same message. Package pgfplots Warning: the current plot has no coordinates (or all have been filtered away) on input line xx. – yngabl Dec 22 '15 at 14:24
• Are we talking about the very same example? If not, take a look at the .tex files in that page, they usually have a commented header that provides some help to compile them. Sometimes you may have to download an extra data file. – filippo Dec 22 '15 at 14:32