Archive for June 2007

Gnuplot-Lua-Terminal

My buddy Peter Hedwig has written a terminal for gnuplot which allows interfacing with Lua. This is interesting for me as in the current configuration it uses Lua to write a TeX source file with PGF/Tikz-instructions which can then be included in LaTeX documents.

“WTF?” you might ask. And you are right in doing so. The usefulness of this becomes clear immediately to people who dislike how their gnuplot plots look when imported as bitmap into a LaTeX document. The fonts aren’t right, lines look wishy-washy, etc. And even if you do get these right, once you change the fonts in your document you have to redo all plots. The gnuplot-lua-terminal solves these issues by using PGF/Tikz. PGF/Tikz is a drawing library for LaTeX. Simply put, your gnuplot plot is translated into a list of LaTeX commands which make sure to use the right fonts, line widths, etc., to achieve a seamless fit into your LaTeX document.

Download it here

MINI-HOWTO:

start gnuplot

set term lua fulldoc
set output “test.tex”
plot (x**2)
plot (x**3)

Then in the terminal run:

pdflatex test.tex

and then use some pdf viewer to look at the result. The default settings of the Lua terminal create a tex file without preamble, etc, so you can include it in your document. With the “fulldoc” option we get a complete LaTeX source including preambel, etc.. Have a look at the included documentation for more info.

Example:

Here you can find an example output.