WinShellIntegrate Gnuplot

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

Integrate Gnuplot

Post by psionman »

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.

Code: Select all

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

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics
User avatar
localghost
Site Moderator
Posts: 9201
Joined: Fri Feb 02, 2007 12:06 pm

Integrate Gnuplot

Post by localghost »

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

Re: Integrate Gnuplot

Post by torbjorn t. »

pgfplots can even use gnuplot to compute the coordinates.
psionman
Posts: 30
Joined: Thu Nov 10, 2011 3:33 pm

Re: Integrate Gnuplot

Post by psionman »

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

Integrate Gnuplot

Post by psionman »

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

But how? I'm using

Code: Select all

\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: 9201
Joined: Fri Feb 02, 2007 12:06 pm

Integrate Gnuplot

Post by localghost »

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

Code: Select all

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

Integrate Gnuplot

Post by psionman »

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

Code: Select all

-synctex=-1 "%s.tex" pdflatex --enable-write18 document.tex
But I still get the message

Code: Select all

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: 9201
Joined: Fri Feb 02, 2007 12:06 pm

Integrate Gnuplot

Post by localghost »

psionman wrote:[…] I have changed the pdfLatex cmdLine in WinShell as suggested. This now reads

Code: Select all

-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.

Code: Select all

-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
User avatar
idb
Posts: 7
Joined: Wed Nov 03, 2021 1:04 pm

Integrate Gnuplot

Post by idb »

Hi,

synctex and enable-write18 are automatically part of the cmd-line call in WinShell.

best regards
Ingo
WinShell developer, www.winshell.org
Post Reply