GNUPLOT

This page will give you some gnuplot basics. A more rigorous treatment of gnuplot can be found here.

gnuplot is a program which plots data. It has a very simple format for its input files:

  1. Each line of the data file contains one point: i.e. an x value and a y value.
  2. Points on consecutive lines are part of the same curve.
  3. A blank line starts a new curve.
Thus, the file:
0 0
3 3
... produces the picture:

i.e. a simple line from (0,0) to (3,3). The more complicated file:

0 0
1.5 1.5
3 0
0 0
... gives us a triangle:

Notice we have to list the first point again at the end. This closes up the triangle.

We can even put the two together:

0 0
3 3

0 0
1.5 1.5
3 0
0 0

Suppose that we have a file triangle.dat which looks like:

0 0
1.5 1.5
3 0
0 0
To plot this with gnuplot you:
  1. Type
    gnuplot
    
    ... to start the program.
  2. then type:
    plot "triangle.dat" with linespoints
    
    to actually make the plot. It'll pop up on your screen.
That's it! We use the "with linespoints" to tell gnuplot to view our file as points connected by lines.
Note: If you work from home and can't use X-windows applications, before plotting you should type:
set term dumb
This'll make gnuplot try to plot with ASCII characters on the screen ... sub-par, but this way you can still work.

To print gnuplot's output, type:

set term postscript
set output "out.ps"
Then, when you plot, the plot will be output as the file out.ps. You can choose any name you want, of course. This will be a postscript file, and that can be printed on any of the University printers.

When you're done, just type quit or exit to leave gnuplot.


This page was stolen from Dr. Christopher Brown.