Blogging about stuff

TeX/LaTeX with Gnuplot on Windows 7

A grad student at work needed help with getting Gnuplot to work with WinEdt 6, a text editor geared towards TeX and LaTeX. I couldn’t find any documentation on how to get the two to work together in Windows, but it can be done. I only needed to get this to work with PDFLaTeX, but this conceivably could work with other output methods in WinEdt.

Prerequsites

First, I’m going to assume that you already have WinEdt 6 and MiKTeX already installed and working. I’m doing this on a Windows 7 x64 machine, but this process would work on any other Windows computer, regardless of x86 or x64.

Install Gnuplot

Gnuplot doesn’t have an automated installer, but if you download the latest version (4.4.3 as of writing), you can extract the file contents. I downloaded “gp443win32.zip” from SourceForge and extracted the folder contents. Copy the “gnuplot” folder to your “C:\Program Files\” directory. Afterwards, you should have a structure like

C:\Program Files\gnuplot>
├───binary
│   ├───etc
│   │   └───fonts
│   └───share
│       └───gnuplot
│           └───4.4
│               ├───js
│               ├───lua
│               └───PostScript
├───contrib
│   └───pm3d
├───demo
├───docs
│   ├───postscript-terminal
│   └───tutorial
└───license
    ├───cairo
    ├───expat
    ├───fontconfig
    ├───freetype
    ├───gd
    ├───jpeg
    ├───libpng
    ├───lua
    ├───MinGW
    ├───pango
    ├───tiff
    ├───win-iconv
    ├───wxWidgets
    └───zlib

Add Gnuplot to path

Next go to the System control panel -> Advanced system settings -> “Advanced” tab -> Environment variables. In the “System variables” section, scroll down to the “Path” variable and edit it. In the “Variable value” box, append a semi-colon and the path to Gnuplot binaries:

Editing path

Editing path

For example, you want to add

;C:\Program Files\gnuplot\binary

to the end of the Path variable. To test and make sure that this works, open up a command prompt or from the Run menu, type “gnuplot” without the quotes and you should see a Gnuplot prompt.

Enable Gnuplot in WinEdt

Now launch WinEdt, and from the Options menu, select “Execution Modes.” In the Accessories list on the left, select “PDFLaTeX”, and in the Switches text box, add

--enable-write18

to allow pdflatex.exe to execute external programs.

Execution options

Execution options

 

I found a code example using TikZ at TeXample.net, copied and pasted it into a new TeX document in WinEdt, clicked the PDFLaTeX button, and voila! I got a nice graph from Gnuplot:

Final output

Final output

 

3 Responses to “TeX/LaTeX with Gnuplot on Windows 7”

  • David

    Thanks a ton for this!

  • CLARO LLAGUNO

    Many thanks. This is very useful/helpful.

  • Antonio Bote

    ¡Muchas gracias, thanks a lot!

  • Leave a Reply