Here we explain how to finish your graph which was prepared as
described before. A plot-file "output.plt"
is a saved file at the last part of
"Numerical Calculations" section. This file contains parameters
and functions, some of those are default ones while the other part is
defined by user. In the following list we eliminated the default
lines, and "set terminal" and "plot" lines are folded.

At the top of this file you may see the part where an output device
(Postscript) and file-name are defined. You can draw the same graph
with this file by using the load command. When you make
another calculation, and the result is stored in "output.dat", you can
reused this plot-file for the new plotting.

gnuplot> load "output.plt"

Alternatively, you can give this file name as a command-line
option when gnuplot is invoked. In this way gnuplot exits after the
last line of the file is read. A graph on your screen disappears at
the same time. To keep the graph on your screen, insert
pause -1 at the end of this file.
The graph stays there till you hit a 'return' key.

% gnuplot output.plt

A command-line option -persist also keeps the graph on
your screen. With this method, gnuplot itself exits but the graph
window settles down.

% gnuplot -persist output.plt

As can be see at the first line of the plot-file, this option is
already included as a shell script option. This option can be used
by giving permission of execution to this file, as follows.

% chmod +x output.plt
% ./output.plt

With this manner you have to close the window every time.

You can continue your work interactively at the gnuplot
command-line once the plot-file is loaded. However, a batch-mode
is more convenient. Firstly, insert pause -1 at the
end of the file, then

Edit the plot-file with a text editor

Browse the graph on a screen

Repeat this sequence until you get a satisfactory figure. If you
are aiming at a Postscript file, your sequence may become:

Edit the plot-file with a text editor

Output the graph in a Postscript data

Preview it with gv (ghostview)

In this case, a comment sign '#' at the beginning of
set terminal postscript and
set output 'output.ps' lines
should be deleted. You don't need pause because no drawing
appears on your screen.

One nice thing to use gnuplot in your scientific activity is that we
can reuse the plot-file to make a similar figure. We often draw very
similar figures those have same axis names, same ranges, etc. but the
numerical data inside the graph are different. With gnuplot you can do
this by using only one plot-file. To do it, change the data file name
at plot "datafile" or use the same data file name but the file
is overridden by various data.

Gnuplot batch mode is very useful when you want to make a large
number of figures at one time. If you are doing this with something
another software, you have to struggle with your computer until
midnight. Why don't you make your life easier with gnuplot and some
UNIX commands to generate many figures within a few seconds.

Here we think about a case that you have many data files ---
calc1.dat, calc2.dat, calc3.dat --- in your directory, and each file
contains simple (X,Y) data. Firstly, we make a graph of the data file,
calc1.dat . Here we define the figure title,
name of axes, X and Y ranges, and graduations, just like we have done in the
numerical calculation section.

A PNG image file is generated by gnuplot, when you "feed" this data.plt file to gnuplot. If you need an EPS
file, use set terminal postscript , and change the name of
output file properly, like calc1.eps.

When you have many files, you can remove the extension '.dat' of
the file name with sed like below. Be careful that there are quotation
and back-quotation marks. The inside sed command is to remove '.dat'
extention of the variable $i , and the outside is to convert
the strings "calc1."

You can also make a shell script to draw figures one-by-one.
Once you make such a script, you can reuse this for other jobs.
The script contains many lines corresponding to the number of
your data files.

To make this you can use the UNIX commands, 'ls' and 'awk'. The
following one-line command shows you the list of commands with which
you can make many figures at one time. To make a shell-script file,
re-direct this output to a file ( command > script.sh ).

As you can see in the example above, the names of data and EPS files
(without extensions) are replaced by a variable $1. The
real names of those variables are given as the command line option
to this shell script plot.sh. This script
makes the EPS file "calc1.eps" from the data file "calc1.dat" when
the command is invoked like below. With this method you can make a
figure of your data files which are in a different directory, and
the result is stored in the same directory.

$ ./plot.sh calc1

To change the names of data file and EPS, you replace one of the
$1 variables in the script above into $2, and give
two command line options to this script.

Finally the next shell script makes it possible to generate many
figures within a second.