Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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.

share|improve this question
2  
You need to run your pdflatex command with the --shell-escape option. Can you check your TeXStudio preferences to see if that's the case? –  Alan Munn Dec 17 '12 at 3:00
1  
See Commands paths in TeXstudio on Mac OS X - with 'could not start the command' error and try adding --shell-escape to the line for pdflatex. –  Alan Munn Dec 17 '12 at 3:11
    
Thanks a million @AlanMunn: It works beautifully! For the future reference, in TexStudio preferences, under Commands, PdfLaTeX is /usr/texbin/pdflatex -synctex=1 -interaction=nonstopmode -shell-escape %.tex. Again, THANK YOU! –  N Nik Dec 17 '12 at 3:25
    
@AlanMunn: Can you please turn this into an answer, then I can accept it? Thank you –  N Nik Dec 17 '12 at 3:26
add comment

2 Answers

up vote 4 down vote accepted

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    
share|improve this answer
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
add comment

@Manuel. I had the same problem, it seems to be an issue with Macports gnuplot. I uninstalled gnuplot, then installed homebrew and used this to install gnuplot. Everything works now.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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