How to ... in GnuPlot (in examples)

Assembled by Ross Bannister, University of Reading



If no screen output is available in installation, try
sudo apt-get update
sudo apt-get install gnuplot-x11

Plot commands

Plotting column a against column b

plot "filename" using a:b with lines/points/ linecolor rgb "colour-name"
(a and b are column numbers)
plot "filename" using ($a/100):b ...

Key label for a particular line

plot ... title ’Plot-title’


Set the line style in following plot commands

set style data lines/points/

Set various labels in following plot commands

set title "plot-title" font ",12"
set xlabel "x-axis-label" font ",12"
set ylabel "y-axis-label" font ",12"

Label the lines in-situ in following plot command

set label 1 ’text for label line 1’

Set aspect ratio for following plot command

set size ratio-x, ratio-y
(e.g. set size 1, 0.5 makes the plot half as high as wide)
set size ratio ratio-value
(e.g. set size ratio 0.5 does the same as the above)

Set tic details

set xtics delta-x font ",12"


unset key
set key
set key bottom right
set key font ",24"


set term postscript color
set output ""

Short cuts

Define multiple line attributes

set style line line-number lt 2 lc rgb "colour-name" lw 2
lt=line type (1=continuous, 2=dashed, 3=dotted, 4=dot-dashed, 5=dot-dot-dashed)
lw=line width
Plot with
plot "file-name" ls line-number