background image
Nice plots in PDF-based TEX-engines such as X E TEX and
pdfTEX using Octave, gnuplot and Xfig
Hans Kunkell
December 4, 2008
Contents
1
Simple Way for LyX Users
1
2
More Advanced Plots
2
2.1
Octave
. . . . . . . . . . . . . . .
2
2.2
gnuplot
. . . . . . . . . . . . . .
2
2.3
Xfig
. . . . . . . . . . . . . . . .
3
2.4
X E TEX/pdfTEX
. . . . . . . . . .
3
2.5
Summarize
. . . . . . . . . . . .
3
3
gnuplot examples
4
3.1
A first plot
. . . . . . . . . . . .
4
3.2
Terminal Test
. . . . . . . . . . .
5
3.3
Various plots
. . . . . . . . . . .
6
3.4
Histograms
. . . . . . . . . . . .
12
3.5
Multiplots
. . . . . . . . . . . . .
13
A Script: Figconverter
15
B Script:
gnuplot
⇒ Xfig ⇒
PDF+TEX
16
Introduction
We all come to situations when we want to insert graphs and plots into our documents. Of
course it is possible to save the graph as an ordinary image and insert, but the result is for sure
not worthy a real L
A
TEX-user.
Until now I’ve been using X E TEX and the reason for that is the ability to easily produce
multilingual texts as well as the ouput to PDF. However, it took some time until I figured out
have to best produce figures and graphs for X E TEX. But now I know, and soon you will also
know!
The aim of this document is to explain one way of including nice figures into X E TEX-
documents. Throughout this document I refer to X E TEX but it will also work for other typeset-
ting engines producing PDFs, such as pdfTEX. First I will describe they way from Octave to
typesetting and finally some examples are shown, which I use myself as quick reference.
This is not a beginners guide in Octave nor gnuplot. I expect you already know how to use
Octave (or Matlab). Regarding gnuplot the first example is easy but the rest is not explained in
that full detail. I recommended you having a look at the Gnuplot L
A
TEX Tutorial if this is the first
time and then the great gnuplot manual. They are both available at
http://www.gnuplot.info
.
I have learnt and borrowed lots from those great sources!
As final words before we begin, I hope this guide will be useful along your way to beautiful
typesetting!
1
Simple Way for LyX Users
For users of LyX (
http://www.lyx.org
the steps are very easy, if you feel you don’t need the
advanced plotting functions of gnuplot. You can create a fig-file directly and use in LyX. To
save current figure in Octave as fig, type in
print -dfig output.fig
to get the graph into the file output.fig. Add -textspecial before the filename to make text
(labels, legends and titles etc) ”special” so they will be typeset by TEX. You may also specify
other options such as -mono or -color mono/color, -solid or -dashed for line type, -portrait
or -landscape for orientation.
After you have saved your fig-file, you just have to choose ”External Material” in the menus
of LyX (Insert > File > External Material) and select ”Template: XFig” and your file. That’s
it!
1