Create scientific plots using gnuplot

March 31st, 2011 | 3 Comments

Beside the epslatex terminal, Gnuplot offers another terminal which can be used in companion with LaTeX. The tikz terminal creates only a tex file without any eps file. The trick is that it uses the tikz environment of LaTeX to draw the whole plot with TeX.

The downside is that this terminal is a new one and not available in the most standard installations of Gnuplot and it could be that there are a few bugs in comparison to epslatex.

In order to install the tikz terminal we have to compile Gnuplot by ourself with the lua flag enabled and install it the usual way:

$ ./configure --with-lua=yes
$ make
# make install

To do so we have to install lua before of course. Under Debian and Ubuntu we have to fix also two links in order to find the lua package:

# ln -s /usr/lib/pkgconfig/lua5.1.pc  /usr/lib/pkgconfig/lua.pc
# ln -s /usr/lib/  /usr/lib/

If the installation is complete, we can use the tikz terminal in the normal way

set teminal tikz

For lots of plots in our LaTeX document we can get a problem with the TeX memory. In order to fix this use more memory for TeX by changing the memory settings in /etc/texmf/texmf.cnf. In Debian and Ubuntu this can’t be done directly, but by editing /etc/texmf/texmf.d/95NonPath.cnf and running

# update-texmf

The memory can be increased by changing the following lines to these new values (which are the maximum values possible).

main_memory = 7999999
extra_mem_top = 7999999
extra_mem_bot = 7999999