4

I would like to plot the following data in a contour plot using pgfplots: data.txt. The data is of the form x_i, y_i, f(x_i,y_i) and contains NaN values. I am able to plot this exact data in a surface plot using pgfplots.

I have read Section 4.6.8 of the pgfplots documentation but I am still unclear on how to do this. This is my attempt at a MWE:

\documentclass{article}

\usepackage{tikz,pgfplots}
\pgfplotsset{compat = 1.8}

\begin{document}

\begin{tikzpicture}
 \begin{axis}[ view = {0}{90} ]
    \addplot3[ contour gnuplot ]
             file {data.txt};
 \end{axis}
\end{tikzpicture}

\end{document}  

The error I get is (the name of my file is plot_data.tex):

PGFPlots: reading {data.txt}
runsystem(gnuplot "plot_data_contourtmp0.script")...disabled (restricted).

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

I receive the same error even when I replace all NaN values for zeros.

Edit I have installed gnuplot. I use Miktex 2.9 with WinEdt 8.0. I have enabled shell escape with the option --tex-option=-shell-escape for the PDFTeXify that I always use. I get the same error as before, but now with some more descriptive text underneath:

Package pgfplots Warning: the current plot has no coordinates 
(or all have been filtered away) on input line 35.

 [warning /pgfplots/warning/plot without coordinates]

Package pgfplots Warning: You have an axis with empty range (in direction z). 
Replacing it with a default range and clearing all plots. on input line 36.

 [warning /pgfplots/warning/empty range cleared axis]

closed as off-topic by Stefan Pinnow, Zarko, Fran, Mensch, Mico Feb 28 '17 at 1:29

  • This question does not fall within the scope of TeX, LaTeX or related typesetting systems as defined in the help center.
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 2
    I think your editor cannot run gnuplot instructions. Do you have the shell escape enabled? – percusse Sep 9 '14 at 8:25
  • 3
    You need gnuplot installed, if you really want to use it for this plot. And maybe you should upgrade to pgfplots-version 1.11 (not needed here, but will do no harm) – LaRiFaRi Sep 9 '14 at 8:26
  • 1
    @Ritz I guess so... haven't tried. For shell-escape, you can read a bit here. Or you search for "<your editor> shell-escape". Or you install arara, write arara: pdflatex: {shell: yes} in the first line of your main.tex and run arara main.tex from your terminal (cmd). – LaRiFaRi Sep 9 '14 at 12:37
  • 1
    Can you check whether your data uses whitespace and end-line characters if any? Looks like it doesn't read off your file properly. When you paste to pastebin it looses all those details. Shorten your data points and try differenct separators. – percusse Sep 9 '14 at 13:17
  • 4
    I'm voting to close this question as off-topic because it works perfectly fine when shell-escape is enabled. – Stefan Pinnow Feb 27 '17 at 23:44

Browse other questions tagged or ask your own question.