I have been working with LaTeX, under TeXMaker (latest version 3.2.2) for several months, and recently added PGF/TikZ capability. On that occasion I feared there would be problems as I really have very little understanding of how the various applications hang together, or even where to find them. But no, once I found where TeXMaker resided I simply added the PGF files as a subdirectory and to my complete surprise, it all worked. Similar success was had with adding tikz-3dplot capability.

Recently, working my way through the TikZ manual I wanted to experiment with gnuplot, and all hell broke loose. I am even unable to find what type or version of LaTeX I am working with, i.e. cannot find executables. I know I have MiKTeX 2.9 loaded as I recall pulling it off the net, but if this is the variant of LaTeX my TeXMaker is working with I cannot tell. The one thing I do find is texmaker.exe, everything else is turning into a complete mystery. Without a doubt I am coming across as a complete air head, but my main interest lies in mathematics, but realize I need to invest effort to make the most of LaTeX and its graphic capabilities as a tool.

Could someone kindly point me to a brief and succinct overview of how the following hang together: LaTeX, TeXMaker, PGF-TikZ, gnuplot. I am working under Windows 7.

  • 2
    gnuplot is a plotting tool that is used outside LaTeX(although there is a package that allows you to use in latex). The output from gnuplot can then be included in a LaTeX document, but LaTeX's own pgfplots will produce nicer results. All depends on what you want to do!? plot some data? or write a beautiful typeseted document? Feb 22, 2012 at 3:47
  • A look at the beginning of a log file from any code you compiled with TeXMaker should show you the version you're working with.
    – DJP
    Feb 22, 2012 at 4:01
  • PGF/TikZ sits on top of TeX, so TeX ultimately does all the work. gnuplot is something entirely different. It is independent, just like any other software for producing graphics. Sure, some packages exist to assist in the creation and use of gnuplot graphics, but the fact remains that they are separate entities. You'll need to get the two talking. Unfortunately this is likely to be more difficult under Windows than it would be for *nix.
    – qubyte
    Feb 22, 2012 at 4:59
  • 1
    Installing new packages (such as tikz-3dplot) are best done via the package manager of your TeX distribution, in your case MikTeX. Open up the start menu and type "package manager" in the search field, and you'll find the MikTeX package manager. Feb 22, 2012 at 12:14
  • I choose this 'Add Comment' facility to thank the four answers I received to my query, and to give a brief update on where it's at: (1) my TeX distribution is indeed MikTeX, Version 2.9 but this was only once I checked the TeXMaker configuration file and learnt that I was able to nominate which to use. (2) I have downloaded gnuplot Version 4.2.4 and am using this standalone, but under Wndows 7 which I am using, no Help is provided. The most recent version of gnuplot (Version 4.4.4) inexplicably does not come as an executable, but as a bunch of C source code files. No luck there. Feb 27, 2012 at 2:14

2 Answers 2


Here's a set of steps I took to get gnuplottex working in Windows. I'm running TeX Live rather than MiKTeX, so let me know if this doesn't work.

First, you need to install gnuplot. The binary I used was taken from this page. When installing it, the only change from the default I made when following the installer was to select "Add application directory to your PATH environment variable." This may not be necessary, but seemed like a good idea.

enter image description here

Next you need to tell Texmaker that it's ok for pdflatex to call external programs. Assuming that you use pdflatex as your typesetter, then you only need to add the --enable-write18 option to the command. To do this, in Texmaker go to Options->configure Texmaker, and add --enable-write18 to the options for the PdfLaTeX command. See the highlighted text in the image below:

enter image description here

Following these steps, try the following example code:

\usepackage{gnuplottex}          % <- Use if running MiKTeX.
%\usepackage[miktex]{gnuplottex} % <- Use instead if running TeX Live.


\begin{gnuplot}[terminal=pdf,terminaloptions={font ",10" linewidth 3}]
    plot sin(x), cos(x)

    set grid
    set title 'gnuplottex test $e^x$'
    set ylabel '$y$'
    set xlabel '$x$'
    plot exp(x) with linespoints

  • Mark, you just provided me with the winning ANSWER! Strangely enough, I had downloaded and installed exactly the same gnuplot 4.5, the only difference is that I followed your advice on 'adding the application directory to my PATH environment variable' this time around. The other is configuring TeXMaker with --enable-write18 rather than --shell-escape. I continue to work with MiKTeX 2.9, replacing TeXLive a few days ago with MiKTeX made my installation a lot more stable. Thank you very much for your help. Mar 3, 2012 at 12:05
  • No problem. I'm glad this worked out for you. :)
    – qubyte
    Mar 3, 2012 at 12:06
  • Mark, is there something I need to do to ensure you get proper recognition for providing the answer to my question? Any boxes to tick? I see the term "up voting" floating around but too busy working on my document to update my expertise on stack exchange protocol. Any advice is welcomed and will be followed. Mar 3, 2012 at 23:11
  • It's been a learning curve on several fronts. I am tickled pink to be getting on with my work again, but I am sure reading up on and experimenting with TikZ, 3dPlot, pgfplots, psTricks(?), Sketch(?) and whatever else there is in graphics will see be coming back with questions and problems. In the longer term I would want to write my own libraries, such as one that draws weight-balanced binary search trees, AVL trees for example, from input parameters. The Object-Oriented facility in TikZ may be one way of attacking this, what other options might there be? Mar 4, 2012 at 12:46
  • I'm not sure about AVL trees (see this question though), but I very highly recommend TikZ for many graphical tasks. For plotting, pgfplots (which sits on top of PGF/TikZ) is probably the easiest way to make beautiful plots and for publishing will even spit out the plots as independent graphics (using the external TikZ library). Take a look at this and this for example.
    – qubyte
    Mar 4, 2012 at 12:56

If you're using TikZ/PGFPlots, you can insert raw gnuplot scripts as in:

% gnuplot script inside brackets {}
\addplot gnuplot[raw gnuplot,mark=none,color=cyan] {
  plot [-10:10] real(sin(x)**besj0(x))

enter image description here

Note the -shell-escape option must be enabled when compiling the document.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .