Using LaTeX in Gnuplot
There are a few different ways to get figures to look pretty when included in LaTeX documents. The main concern is to have the font of the figure to match that of the rest of the document. The easiest way to do this is to compile all the text with LaTeX rather than trying to specify specific fonts yourself. Options include:
- Using the
figterminal and converting to eps or pdf with thefig2epsorfig2pdfutilities from the fig2ps project. - Using a terminal like
epslatex. This generates both tex and eps files which can be included in any LaTeX document or combined into one file for use elsewhere.
Using the fig terminal
An advantage to using the fig terminal over the epslatex method is
that the Gnuplot output is readily editable in xfig. However, the
point type numbers in the fig terminal are completely different than
most other terminals, so this can be troublesome if you want to be
able to have different outputs that look similar. Another annoyance is
using xfig and fig2ps on Windows (which I am forced to do in the lab).
If these disadvantages don't bother you, you'll just need to add
set terminal fig
set out 'output.fig'
to your set of Gnuplot commands. Then convert to EPS with fig2eps
--forcespecial output.fig.
Using the epslatex terminal
To use the epslatex terminal, add
set terminal epslatex
set out 'output.tex'
to your list of Gnuplot commands. The output will result in two files:
output.tex and output.eps. Opening up output.eps will show all
graphical elements but not the text. If you are ok with having two
separate files and want to include this directly in a LaTeX document,
you need to add \input{output.tex} where appropriate (usually within
a figure environment).
Alternatively, the two files can be combined by processing through
latex. I have written a Python script to
automate this.

