SESSION 16		GNUPLOT : A GRAPHICS PACKAGE


1. Gnuplot is a fast and effective graphics package available on all UNIX 
machines which will allow us to plot 2D, 3D and 3D contour graphs. We can plot 
graphs from a datafile or by specifying a formula. Use of Gnuplot will be 
introduced by means of two examples which illustrate sufficient of its features 
for our purposes. 

2. Gnuplot may plot a 2D graph in the following two ways:

a) y versus x from a data file. 
If you wish to plot more than one set of data on the same picture, this may 
be presented as a second data file or as part of a datafile in which each 
dataset is separated by a blankline. Each set, by default, is plotted using a 
different symbol.

b) y versus a function of x where the function is one of the standard set of
mathematical functions (sin, cos tan, exp, ....). An expression which is some
algebraic combination of these is also acceptable. These may be coded exactly
as a Fortran expression (see below)

[Gnuplot can also plot polar and parametric functions and also polar plots from 
a multi-column datafile (where the x and y columns represent theta and r)].

3. The graphs to be plotted may be customised by a collection of 'set' 
commands. If any are omitted then default values are assumed. They are:

a) set term x11			sets the terminal type to `x11'. (When entering
                                gnuplot this should be set automatically)
c) set data style lines		sets the style (lines, points, dots, 
				linespoints, etc.) of representation of data
d) set size 4/5.,3/4.		sets the size of box inside which data appears
e) set title "text"		sets a title `text' to appear on top of the box
f) set xlabel "text"		sets a label `text' along the x-axis
g) set ylabel "text"		sets a label `text' along the y-axis
h) set key -5,4.5		sets up a key of plotted data and symbols used
				Top symbol placed at point `-5,4.5' on the 
				scale specified (see below)
   set nokey			no key is displayed
i) set xtics -3*pi,pi		sets the tick marks on the x axis to start at
				-3*pi, and thereafter at intervals of pi
j) set ytics -5,2		sets the tick marks on the y axis to start at
				-5, and thereafter at intervals of 2
l) set label "text" at -3.5,-4 right
				positions the label `text' in the box with its
				right end at -3.5,-4

The coordinates specified above are relative to the coordinate system as 
stipulated for the box in the `plot' command (see next).

4. Plots are made simply by typing 

		plot   or simply   p

together with information specifying

a) the range for x and y
b) the function or datafile to be plotted
c) the columns which represent x and y (if not the 1st and 2nd)
d) the style if not the same as given in the `set' statement

e.g.	p [0:5][-pi:pi] `fort.99` u 1:3 w l 2

However a plot command can be as simple as
	
	p `fort.99`     or    p  exp(x**2-3/x)



5. Two example graph plotting files, `graph1' and `graph2', appear in 
the subdirectory `gnu' within your `unixses' directory. You should read 
these and be able to reproduce the plots on the screen and obtain a 
hardcopy. Two data files `fort.11' and `fort.12' are also supplied. 


6. Exercises:

a) Plot the function `y = x*x' with x in the range [-10:10], 
			        and y in the range [0:100].
   Label the axes and give the plot a title.
   Try different styles, e.g. lines, dots, symbols.
   Insert or move the key to some appropriate position in the box.

b) Plot the function `x*x*tan(x)' with x in the range [0:1.55]
				   and y in the range [0:50]
   Change the interval between the tick marks on the two axes.

c) Plot `exp(-x*x)' and `tanh(x)' on the same graph choosing your own limits.
   Insert a key at an appropriate position

d) Plot BOTH columns 1 vs 3 and columns 3 vs 2 from the file `fort.12' which 
   resides in the directory `gnu'. Plot the first of these curves using a 
   line and the second using linespoints.

e) Using the gnuplot help facility, ascertain what command is required
   to remove all tickmarks from the x-axis. (Your initial help topic
   should be `set').


END OF SESSION 16					file gnu16
