Graphics, Figures & TablesHow can I draw plots in LaTeX?

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
ditka
Posts: 85
Joined: Fri Jul 13, 2012 11:59 am

Re: latex,gnuplot

Post by ditka »

I have done that, I can call gnuplot from command line, gnuplot itself also work, I also tried with older versions og gnuplot.

Nothing of that didnt help.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

ditka
Posts: 85
Joined: Fri Jul 13, 2012 11:59 am

Re: latex,gnuplot

Post by ditka »

Well, I think pgf have its qualities and gnuplot has its own.
Probably not calling external program is good advantage, but there are also other parameters.

And I think I could use gnuplot, but I just cant find what is wrong. As I mentioned before, I get the identically same result, using either PCTeX or MIKTeX, so it must be something with gnuplot, ot its connection with latex.

I alredy post log file from both editors, but they didnt show exactly where the problem is.

I also look at all requirements, that I found on the web page with example and I think I have manage to satisfy them all.

So, I please if somebody(using windows, and latest wersionon of gnuplot ) can tell me how its output look like.(like did Stefan in the second post) so I can see is there something wrong with using this code in widows or is the problem in my computer.
And I also please if somebody has any idea what else can I check or where to look to find solution.
ditka
Posts: 85
Joined: Fri Jul 13, 2012 11:59 am

Re: latex,gnuplot

Post by ditka »

I have now try unninstal gnplot and I still get the same picture.

I have read post under the graph(on the original page with istructons for picture) that something in the file pgfmodule.code need to be changed. I have attach the file, here, if anaybody have any suggestion what can I change here.
Attachments
dsd.pdf
(121.28 KiB) Downloaded 585 times
ditka
Posts: 85
Joined: Fri Jul 13, 2012 11:59 am

Re: latex,gnuplot

Post by ditka »

Can please somebody that can use gnuplot in latex post his pgfmodule.code file?
User avatar
shadgrind
Posts: 140
Joined: Thu Jul 16, 2009 12:39 am

How can I draw plots in LaTeX?

Post by shadgrind »

If you want to use gnuplot with LaTeX, I'd recommend using them as separate programs instead of trying to call gnuplot directly from LaTeX. Gnuplot has two terminal types which produce LaTeX-friendly output: epslatex and lua. Both of those draw only the graphics parts and leave the text rendering to LaTeX, so that you can get the same fonts (both normal and math mode) on the plots as in the rest of your document. See here for an example of using the epslatex terminal in gnuplot, and see here for an example of using the lua terminal for inclusion in TikZ environments.
System: TeX Live 2012, Fedora 18 x86_64, GNU Emacs 24.2
ditka
Posts: 85
Joined: Fri Jul 13, 2012 11:59 am

How can I draw plots in LaTeX?

Post by ditka »

After I use the folowig example I get:

Code: Select all

    \documentclass{article}
    \usepackage{pgfplots}

    \begin{document}
      \begin{tikzpicture}
        \begin{axis}[%
          xlabel={x},
          ylabel={$\left(\frac{\sin(x)}{x}\right)^2$},
          xmin=-10,xmax=10,ymin=0,ymax=1,
          xtick={-10,-5,...,10},
          ytick={0,0.2,...,1}
        ]
          \addplot[domain=-10:10,samples=100] gnuplot {(sin(x)/x)**2};
        \end{axis}
      \end{tikzpicture}
    \end{document}
! Package pgfplots Error: Sorry, the gnuplot-result file 'ffgsffsfsfs.pgf-plot.
table' could not be found. Maybe you need to enable the shell-escape feature? F
or pdflatex, this is '>> pdflatex -shell-escape'. You can also invoke '>> gnupl
ot <file>.gnuplot' manually on the respective gnuplot file..

See the pgfplots package documentation for explanation.
Type H <return> for immediate help.

error.

Why is better using gnuplot as two separate progrmas?
User avatar
cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

How can I draw plots in LaTeX?

Post by cgnieder »

ditka wrote:

Code: Select all

! Package pgfplots Error: Sorry, the gnuplot-result file 'ffgsffsfsfs.pgf-plot.
table' could not be found. Maybe you need to enable the shell-escape feature? F
or pdflatex, this is '>> pdflatex -shell-escape'. You can also invoke '>> gnupl
ot <file>.gnuplot' manually on the respective gnuplot file..

See the pgfplots package documentation for explanation.
Type  H <return>  for immediate help. 

error.
It runs flawless for me. Did you run it with »shell-escape« enabled?
site moderator & package author
ditka
Posts: 85
Joined: Fri Jul 13, 2012 11:59 am

Re: latex,gnuplot

Post by ditka »

Yes, I did. Like I said in previus posts it looks like latex cant contet to external programs.
User avatar
shadgrind
Posts: 140
Joined: Thu Jul 16, 2009 12:39 am

How can I draw plots in LaTeX?

Post by shadgrind »

ditka wrote:Why is better using gnuplot as two separate progrmas?
For precisely the reason you're having trouble trying to use them together. :D

It's just much easier to use gnuplot and LaTeX separately. Another advantage is that for large documents you don't have to wait a long time for the LaTeX compilation to end to see what the plot will look like; you could just run gnuplot separately and immediately see how the plot looks.
System: TeX Live 2012, Fedora 18 x86_64, GNU Emacs 24.2
User avatar
cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

How can I draw plots in LaTeX?

Post by cgnieder »

shadgrind wrote:It's just much easier to use gnuplot and LaTeX separately.
Well, that depends... for the example above I had to hit one (!) button only. Can't get much easier than that… :)
shadgrind wrote:Another advantage is that for large documents you don't have to wait a long time for the LaTeX compilation to end to see what the plot will look like; you could just run gnuplot separately and immediately see how the plot looks.
That's why I always have a second file (usually test.tex) opened in my editor. No need to compile the whole document. :)
site moderator & package author
Post Reply