To use gnuplot, put your data in a file that looks like this

and then type the following command to get gnuplot to plot it on your terminal:

gnuplot>plot "example-data"

where example-data is the name of your data file. single or double quotes both work.

The following sequence of commands will output that plot to a postscript file (myplot.ps, in this example) instead of your terminal:

gnuplot>set term postscript

('set term postscript enhanced color' also works here)

gnuplot>set output "myplot.ps"

('set term pdf' also works here)

gnuplot>plot "example-data"

You can then send the postscript file to a printer or cut'n'paste it into another document.

If your datafile has a bunch of columns, like this, you can tell gnuplot which ones to plot using 'using':

gnuplot> plot 'multicolumn-data' using 0:1

The default point shape is a little diamond. If you want smaller dots, use the "with dots" option:

gnuplot>plot "example-data" with dots

The "with lines" option lets you draw lines between successive points in the data file. (Don't use this option for CSCI 4446/5446!) If you are using this option but DON'T want lines drawn between some pair of successive points, you have to leave a blank line between those points in the data file. See this file for an example.

There are a lot more options and bells and whistles to gnuplot; it can plot in 3D, rotate stuff, etc. Below is an example contributed by Michael W.; it shows you how to change the point size, add titles and label axes, use png format instead of ps, etc. # is the comment character.

gnuplot> set pointsize 0.2 # make small dots

gnuplot> set time # add timestamp

gnuplot> set title "Fixed Point for Time Series Plot of x(n+1) = Rx(n) (1 - x(n))" # add title

gnuplot> set xlabel "n" # add x-label

gnuplot> set ylabel "xn" # add y-label

gnuplot> set nokey # don't put filename "fixed_point.txt" in graph

gnuplot> plot "fixed_point.txt" # plot data points

gnuplot> set terminal png # tell gnuplot to make png image

gnuplot> set output "fixed_point.png" # set png file

gnuplot> replot # plot to png file

gnuplot> quit

Please explore the help docs or the man pages if you want to learn more.

If you want to plot different things in different colors, here's an example:

plot "file1" title "caption for file 1" with points pt 1, "file2" title "caption for file 2" with points pt 2

pt means point type. If you type in test in gnuplot, it will show you the various point types (with different colors). Beware, because this is not how the point types turn out if you are using postscript. You can also use "with lines" instead of "with points" and there is a corresponding linetype (either ls or lt I think).