LaTeX forum ⇒ WinShellIntegrate Gnuplot

Information and discussion about WinShell, a free integrated LaTeX environment for Windows
psionman
Posts: 30
Joined: Thu Nov 10, 2011 3:33 pm

Integrate Gnuplot

Postby psionman » Thu Nov 10, 2011 3:41 pm

Hi

I'm running WinShell under Windows and I was wondering if anyone could help me call Gnuplot 'plot' command directly from LaTeX source?

e.g.
  1. plot sin(x)/x


I can generate .tex files from Gnuplot and use in my LaTeX documents with '\input' with no problem, but it's a bit long winded

Thanks

User avatar
localghost
Site Moderator
Posts: 9206
Joined: Fri Feb 02, 2007 12:06 pm

Postby localghost » Thu Nov 10, 2011 6:38 pm

Take a look at the gnuplottex package. But there are much smarter ways to produce plots by the pgfplots package (based on pgf/tikZ) or the pst-plot package (based on PSTricks).


Best regards and welcome to the board
Thorsten
LaTeX Community Moderator
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes


¹ System: openSUSE 42.2 (Linux 4.4.52), TeX Live 2016 (vanilla), TeXworks 0.6.1

torbjorn t.
Posts: 162
Joined: Wed Jun 17, 2009 10:18 pm

Postby torbjorn t. » Thu Nov 10, 2011 7:19 pm

pgfplots can even use gnuplot to compute the coordinates.

psionman
Posts: 30
Joined: Thu Nov 10, 2011 3:33 pm

Postby psionman » Thu Nov 10, 2011 8:22 pm

Thanks both

As a LaTeX newbie, I'd never heard of pgplots - looks good so far

psionman
Posts: 30
Joined: Thu Nov 10, 2011 3:33 pm

Postby psionman » Thu Nov 10, 2011 11:11 pm

torbjorn t. wrote:pgfplots can even use gnuplot to compute the coordinates.


OK :)

But how? I'm using

  1. \addplot gnuplot[id=sin]{sin(x)};


and I get the message:

pgfPlots.tex(21): Error: Package pgfplots Error: Sorry, the gnuplot-result file 'pgfPlots.sin.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 <file>.gnuplot' manually on the respective gnuplot file

User avatar
localghost
Site Moderator
Posts: 9206
Joined: Fri Feb 02, 2007 12:06 pm

Postby localghost » Fri Nov 11, 2011 12:27 pm

You have to compile the concerned document with activated shell escape. Assumed that you are using the MiKTeX distribution it should read like this.
  1. pdflatex --enable-write18 document.tex

Your editor should allow in its options to add this switch to the command line arguments for the compiler so that it is always invoked with activated shell escape.

Furthermore you have to make sure that Gnuplot can be found. Therefore you have to supplement the »Path« variable with the path of Gnuplot. This requires that you remember where you unpacked the archive at that time.
LaTeX Community Moderator
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes


¹ System: openSUSE 42.2 (Linux 4.4.52), TeX Live 2016 (vanilla), TeXworks 0.6.1

psionman
Posts: 30
Joined: Thu Nov 10, 2011 3:33 pm

Postby psionman » Sat Nov 12, 2011 6:18 pm

Thanks localghost

I'm sorry, but I really need to be hand-held through this

I have gnuplot in my PATH; specifically if I type in gnuplot from any directory in Command Prompt the program starts

I have changed the pdfLatex cmdLine in WinShell as suggested. This now reads
  1. -synctex=-1 "%s.tex" pdflatex --enable-write18 document.tex


But I still get the message

  1. pgfPlots.tex(20): Error: Package pgfplots Error: Sorry, the gnuplot-result file 'pgfPlots.sin.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 <file>.gnuplot' manually on the respective gnuplot file..


Can you help?

User avatar
localghost
Site Moderator
Posts: 9206
Joined: Fri Feb 02, 2007 12:06 pm

Postby localghost » Sat Nov 12, 2011 7:31 pm

psionman wrote:[…] I have changed the pdfLatex cmdLine in WinShell as suggested. This now reads
  1. -synctex=-1 "%s.tex" pdflatex --enable-write18 document.tex

[…]

I can't remember that I told you to insert exactly what I suggested. What I told you was only to supplement the command line arguments for the compiler with the --enable-write18 switch.

Since I don't use WinShell I can only assume the right settings for this editor. I guess that in the corresponding WinShell options there is a box for the executable of the compiler (PDFLaTeX) and a separate box for its command line arguments. Thus the command line arguments should read at least like this.
  1. -synctex=-1 --enable-write18 "%s.tex"

That should suffice to invoke external programs like Gnuplot by the compiler. If this works with the pgfplots package, it will also work for any other package that needs shell escape.
LaTeX Community Moderator
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes


¹ System: openSUSE 42.2 (Linux 4.4.52), TeX Live 2016 (vanilla), TeXworks 0.6.1


Return to “WinShell”

Who is online

Users browsing this forum: No registered users and 1 guest