Gnuplot Tutorial
R F Evans
Introduction
Gnuplot is the worlds best 2D
graphing package:
Highly customisable
Scriptable
Produces very professional
graphs
Small file sizes
Fast and lightweight
Available as a standard linux
package
Scientific plotting recap
Graphs of scientific data need the following:
Title (or figure caption)
What
are you plotting against what?
(Caption)
Axis labels
Units
What do the lines mean?
Gnuplot in practice
Generate data for Gaussian function
Plot with p "./[Link]" u 1:2 w lp
p stands for plot (data file)
u stands for using (columns)
w stands for with
lp stands for linespoints
Gnuplot in practice
Lets set a more appropriate yrange and name our plot
p [][0:1.1]"./[Link]" u 1:2 w lp ti Data
ti is short for title
Gnuplot in practice
Lets add a title and axis labels
set title Plot of Gaussian function
set xlabel Value
set ylabel Probability
replot
Gnuplot in practice
A box histrogram would look nicer in black
p [][0:1.1]"./[Link]" u 1:2 w boxes lt -1 ti
"Data
lt is line type
Gnuplot in practice
Hmm too many boxes
p [][0:1.1]"./[Link]" every 4 u 1:2 w boxes lt -1
ti "Data
every specifies that every nth point is plotted
Gnuplot in practice
Finally output graph to file:
set terminal postscript eps enhanced color "Palatino" 16
Here the font is set to Palatino there are others
set output [Link]
Gnuplot Scripting
This can all be put in a script; [Link]
# Set Terminal type
set terminal postscript eps enhanced color "Palatino" 16
# Set graph title
set title "Plot of Gaussian Function"
# Set axis labels
set xlabel "Value"
set ylabel "Probability"
# Set output file
set output "[Link]"
# Plot data
p [][0:1.1]"./[Link]" every 4 u 1:2 w boxes lt -1
# Convert file to pdf at the end
sys "epstopdf [Link]
The script can then be run by typring:
Gnuplot [Link]
ti "Data"
Gnuplot in practice
Extra info:
[Link]
[Link]/~marti/repartidos/[Link]