6

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 the gnuplottex at 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?

Thank you in advance.

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

  • Have you seen How to enable shell-escape in TeXworks? – Torbjørn T. Apr 3 '15 at 13:59
  • @TorbjørnT. I have but the version of TeXWorks discussed is a much older one and many settings have changed. I cannot quite follow it. – JohnK Apr 3 '15 at 14:02
  • Huh? Looks exactly the same as the one I have, which according to Help -> About Texworks is version 0.5. Which version do you have, and how does the Preference-window look? – Torbjørn T. Apr 3 '15 at 14:05
  • @TorbjørnT. Oh dear, it's not TeXworks but Texmaker the one I am working with. Very sorry for the confusion. I amended the name. – JohnK Apr 3 '15 at 14:07
  • possible duplicate of gnuplottex with windows 8.1 – egreg Apr 3 '15 at 14:09
2

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

  • @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 3 '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 windowsitpro.com/systems-management/… on how to do that. – moewe Apr 3 '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 3 '15 at 15:11
  • It should be C:\Program Files (x86)\Gnuplot\bin. – Bernard Apr 3 '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 3 '15 at 15:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.