Finally I have decided to go PDF. I can add pictures without EPS wrapper, and do drawings with TikZ - life is good :o)

But how do I use gnuplot? For consistency I would like to use the tikz terminal, and I would like to be able to preview my graphs without including them in a document. This

set term tikz standalone preamble '\usepackage[version=3]{mhchem}'
set output "test.tex"
plot x title '\ce{H2O}'

will make an article class document that can compile alone, but it can not be included in another document.

One solution would be not to use the standalone option, and then make a small script, that wraps the output in the standalone class. Now the document can compile alone, and it can be included in a document, but I would not be able to specify an additional preamble. :o(

Does anyone have a smart solution?

  • Did you try KtikZ (QtikZ) ? You can edit the preamble of the compiling document for further modifications. – percusse Dec 3 '11 at 5:03
  • 1
    I would recommend you use PGFplots, which can use gnuplots to do the calculations, but creates the plots directly in your LaTeX document. – Jake Dec 3 '11 at 5:14
  • Apropos of @Jake's comment, tikz itself has a \draw plot function {...}; operator that passes the braced function straight to gnuplot. See the 2.10 manual, section 19.6. – Ryan Reich Dec 3 '11 at 5:31
  • I think that Hans-Peter wants to work initially in gnuplot to figure out the plot parameters and stuff, and only go to TeX for when it is to be included in the document. Am I right? In which case a simple script to strip out the preamble would seem simplest. Can you post a typical file from gnuplot? Both with and without the preamble stuff. – Loop Space Dec 3 '11 at 6:02
  • 1
    @Hans-PeterE.Kristiansen: You can edit your question to include example code. I would still recommend PGFplots instead of using Gnuplot's TikZ terminal. It has all the automatic plot features, but it generates much nicer legends and titles, and in my experience it's easier to annotate your plots. – Jake Dec 3 '11 at 7:07

With standaloneand gnuplottexyou can get only the picture but pgfplots is preferable because it's hard to manage the font for the labels between gnuplot and latex


      plot x title '\ce{H2O}'

enter image description here

  • Oooh - I think that is a solution. Instead of writing a gnuplot script, I write in latex using gnuplot. But I can still use the TikZ terminal! – hpekristiansen Dec 3 '11 at 20:08
  • :I can not compile your example - when trying pdflatex -shell-escape test.tex, I get ! Undefined control sequence. \gnuplotverbatimwrite ...e \openout \verbatim@out #1 \BeforeStream \let \do ... l.7 p lot x title '\ce{H2O}' – hpekristiansen Dec 3 '11 at 20:10
  • I managed to compile the example after editing the gnuplottex.sty as described by sdaau here: tex.stackexchange.com/questions/16393/… – hpekristiansen Dec 3 '11 at 23:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.