6

I have to draw a lot of PDF and CDF graphs in my document/presentation and in order to do that I installed gnuplot. In order to install gnuplot I took the following steps:

1- Download the sources from : gnuplot sources then put the folder gnuplot-4.4.3 on my desktop 2- $ cd /Users/.../Desktop/gnuplot-4.4.3 3- $ ./configure --with-readline=builtin 4- $ make 5- $ sudo make install 6- test of gnuplot $ gnuplot gnuplot works from Terminal. However, I get a lot of error running the followingMWE

\documentclass{minimal}
\usepackage{amsmath}
\usepackage{pgfplots}

\def\cdf(#1)(#2)(#3){0.5*(1+(erf((#1-#2)/(#3*sqrt(2)))))}%
% to be used: \cdf(x)(mean)(variance)

\DeclareMathOperator{\CDF}{cdf}

\begin{document}
    \begin{tikzpicture}
    \begin{axis}[%
    xlabel=$x$,
    ylabel=$\CDF(x)$,
    grid=major]
    \addplot[smooth,red] gnuplot{\cdf(x)(0)(1)};
    \addplot[smooth,blue]gnuplot{\cdf(x)(0.5)(1)};
    \addplot[smooth,green]gnuplot{\cdf(x)(1)(1)};
    \addplot[smooth,orange]gnuplot{\cdf(x)(2)(1)};
    \end{axis}
    \end{tikzpicture}
\end{document}

The error that I get is

pgfplots: Sorry, the gnuplot-result file 'texstudio_DH7974.pgf-gnuplot <file>.gnuplot' manually on the respective gnuplot file.. \addlegendentryexpanded{$k = \k$}}

or code given in plotting chi-square. I guess I am missing one (or maybe cuple) of steps installing gnuplot. I really appreciate if you help.

N Nik
  • 3,669

1 Answers1

5

Since you can run gnuplot from the Terminal, you have installed it correctly. But you also need to configure pdflatex to allow it to run external programs. Since you are using TeXStudio you need to go into its preferences and change the entry for pdflatex. See

for details on this. So the correct line to allow you to run gnuplot from within a LaTeX document is:

 pdfLaTeX    "/usr/texbin/pdflatex" -synctex=1 -interaction=nonstopmode -shell-escape %.tex    
Alan Munn
  • 218,180
  • 2
    Well, I'm in a very similar situation, and this command doesn't work for me. I have Mountain Lion 10.8.2, with TeXworks, TeXShop and TextMate. I installed gnuplot from MacPorts (and it works from the terminal). If I call it from any of those three programs it gives me an error (and I have to manually execute gnuplot from the terminal). I don't know what happens (it worked well in Snow Leopard). – Manuel Dec 17 '12 at 17:30
  • 1
    @Manuel This sounds like a path problem. Do you get the same error as above, or something different? – Alan Munn Dec 17 '12 at 18:23
  • 1
    Package pgfplots Error: Sorry, the gnuplot-result file 'untitled.pgf-plot.table' could not be found. Maybe you need to enable the shell-escape feature? For pdflatex, this is '>> pdflatex -shell-escape'. You can also invoke '>> gnuplot .gnuplot' manually on the respective gnuplot file. How can I solve that PATH problem (it's true, TextMate usually asks to set PATH, but this time it didn't). – Manuel Dec 17 '12 at 18:40