0% found this document useful (0 votes)
127 views

GnuPlot Tutorial

This document provides an introduction and tutorial to Gnuplot, an open-source 2D plotting utility. It discusses key features of Gnuplot including being highly customizable, scriptable, producing professional graphs, and having small file sizes. The tutorial then demonstrates how to generate and plot sample Gaussian data, customize the plot by setting ranges, labels, and styles, and output the final graph to a file. It emphasizes that Gnuplot configurations and commands can be saved into scripts for easy re-plotting.

Uploaded by

daongocha108
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
127 views

GnuPlot Tutorial

This document provides an introduction and tutorial to Gnuplot, an open-source 2D plotting utility. It discusses key features of Gnuplot including being highly customizable, scriptable, producing professional graphs, and having small file sizes. The tutorial then demonstrates how to generate and plot sample Gaussian data, customize the plot by setting ranges, labels, and styles, and output the final graph to a file. It emphasizes that Gnuplot configurations and commands can be saved into scripts for easy re-plotting.

Uploaded by

daongocha108
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

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 "./data.dat" 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]"./data.dat" 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]"./data.dat" u 1:2 w boxes lt -1 ti
"Data
lt is line type

Gnuplot in practice

Hmm too many boxes

p [][0:1.1]"./data.dat" 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 plot.eps

Gnuplot Scripting
This can all be put in a script; plot.gpl
# 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 "plot.eps"
# Plot data
p [][0:1.1]"./data.dat" every 4 u 1:2 w boxes lt -1
# Convert file to pdf at the end
sys "epstopdf plot.eps

The script can then be run by typring:

Gnuplot plot.gpl

ti "Data"

Gnuplot in practice

Extra info:

http://t16web.lanl.gov/Kawano/gnuplot/index-e.html
www.fisica.edu.uy/~marti/repartidos/gnuplotbook1.pdf

You might also like