7

This is a frequently asked question but none I have seen actually helped me. My problem is that I installed Gnuplot 5 and I have not been able to make it work in the TeXworks. The figure I have been trying to plot is this:

\documentclass[11pt]{article}
\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{compat=1.5}
\usepackage{listings}
\usepackage{pgfplots}
\usepackage[miktex]{gnuplottex}


\begin{document}

    \begin{tikzpicture}
    \begin{axis}
    [
        title={Contour plot, view from top},
        view={0}{90}
    ]
    \addplot3[
        contour gnuplot={levels={0.8, 0.4, 0.2, -0.2}}
    ]
    {sin(deg(sqrt(x^2+y^2)))/sqrt(x^2+y^2)};
    \end{axis}
    \end{tikzpicture}
\end{document}

As many answers have suggested I tried to call gnuplottex in the preamble with the code

\usepackage[miktex]{gnuplottex}

yet this did not help and instead I have been getting the error

Package pgfplots Error: sorry, plot file{.._contourmp0.table} could not be opened. See the pgfplots package documentation for explanation 

followed by the warning that Shell escape is not enabled.

Could you please help me in making this work?

EDIT I am aware that there is a phenomenally identical question on this site, namely gnuplottex with windows 8.1 but it does not address my problem. The problem persists even after using \usepackage[miktex]{gnuplottex}, as I pointed out from the beginning.


Following suggestions, I have made sure there is a path towards the bin directory and have included the statement --enable-write18 in the PdfLaTeX command line of TeXworks. All other suggestions are of course welcome.

Also here is my attempt to compile through the command line:

enter image description here

And my Texmaker configuration:

enter image description here

epR8GaYuh
  • 2,432
JohnK
  • 354

1 Answers1

5

You seem to have a MiKTeX distribution. Add the --enable-write18 option to pdflatex options by opening the Options menu, Configure TeXmaker submenu. You'll get this pop-up window:

enter image description here

Bernard
  • 271,350
  • @JohnK It might just be me, and I have no tested it, but on my machine I have in the past successfully used -enable-write18 with just one dash. – moewe Apr 03 '15 at 14:48
  • @JohnK You will have to locate the folder with gnuplot.exe in it (on my system that is C:\Program Files (x86)\gnuplot\bin) and add that directory to the PATH variable, see http://windowsitpro.com/systems-management/how-can-i-add-new-folder-my-system-path on how to do that. – moewe Apr 03 '15 at 15:01
  • @JohnK No, you will have to have something pointing to the bin directory. That might not solve the problem, though. I was just able to reproduce your issue on my computer. The problem seems to be that the file <tksjs>_contourtmp0.table is not created by the packages. – moewe Apr 03 '15 at 15:11
  • It should be C:\Program Files (x86)\Gnuplot\bin. – Bernard Apr 03 '15 at 15:16
  • @JohnK Have you tried running the compilation of the .tex file from the command line? Via pdflatex -enable-write18 <filename without extension>. If you have changed the PATH the old "have you tried turning it off and on again" trick might help. If all fails, please prepare a MWE and update your question. – moewe Apr 03 '15 at 15:34
  • @moewe Well, the command is accepted now and many lines of code are generated with some warnings though, for instance "You have requested the package ', but the package provides 'pgffor'". – JohnK Apr 03 '15 at 16:05
  • @JohnK Aha! That is very interesting! Please show us the actual file you are running, but make sure it is a MWE - you can add the file to your initial question. Also add the warnings and errors you get during compilation. – moewe Apr 03 '15 at 16:08