GnuPlot (output terminals and symbol screening)

Character screening
Transparency with epslatex

When creating your beautiful scientific plots you can make use of the full power of GnuPlot. Here you can find a brilliant description of the output terminals that you make use. I would like to point to ‘epslatex’ output terminal which allows you to use the font from the main LaTeX document as well as all the various math symbols (for sure you can use PgfPlots to do the same thing). It basically creates the two files: the graphics (as .eps file) and the annotations in LaTeX format (.tex file), where the latter has to be compiled in order to receive the final graphics with nice annotations. You can use that in the standalone mode. The choice depends on how would you use that in your final LaTeX file or just like standalone graphics.

the code below was tested using gnuplot 4.6

Character screening

Please note that if you use gnuplot in this way

#!/bin/sh
gnuplot << EOT
….gnulot commands…
EOT

and you use scripts from that page directly under linux systems, you can encounter some weird mistakes generated by your LaTeX processor. Usually it is related to the unbalanced ‘$’ symbols. Don’t forget to screen ‘/’ them! (I don’t know if one shall do the same under Windows). The error messages can be accompanied by

Extra }, or forgotten $ \gplbacktext
Missing $ inserted \gplbacktext
Missing } inserted \gplbacktext

It means that instead of having

set xlabel ‘$x$’

one shall use

set xlabel ‘\$x\$’

The reason is the way of how the symbols are going into the input of gnuplot command.

On the other hand you can store your gnuplot commands in the separated file “script.plt” and do

gnuplot script.plt

where you don’t need to screen characters. It makes the whole thing easier and you do not need to find where the error was.

Transparency

You find nice examples on how to create transparent curves here and a little bit more details here. However there is again an issue with “epslatex” output terminal. Probably it is only my experience but using epslatex can create issues with transparency. So I followed the advice given here and switched to use “cairolatex”.

Leave a Reply