The program has two different modes, interactive and batch. In the interactive mode, a user sits at the terminal and plots various data files or functions while the results are displayed to the screen. In batch mode, the commands to create the graphs are read from an input file and the output can be sent to another file that can be incorporated into a web page.
Plotting a Math Function|
The following example shows how to call up gnuplot and plot the curve y = sin(x). The command "plot sin(x)" will assume a number of standard parameters will be used and will display the graph to the screen.
bash-2.03$ gnuplot Terminal type set to 'x11' gnuplot> gnuplot> plot sin(x);
Plotting Existing Data from a File|
To display the numbers in an existing file called "temp", just type the command "plot" followed by the file name in quotes, as well as other parameters such as "with lines" to indicate the format of the graph. The file just contains a sequence of simple floating point values between 0.0 and 5.0, so gnuplot assumes the x-coordinates are consecutive integers.
gnuplot> plot "temp" with lines;Refer to the extensive online help to see how to work with other data types or display formats such points (the default), lines, and histogram type boxes. This program has many features!
To get out of gnuplot, just type "quit".
In order to run the commands stored in a file called "input1.txt",
the following command would be run:
Depending upon the the content of the input file, many different outcomes are possible. The following sample input file will first set the output file name to "outfile1.png", and then change the "terminal type" from the standard X-windows interface to a color PNG file (similar to GIF only it does not have the copyright problems.) The final command just plots the file "temp" as before, only with a different format using histogram-like "boxes". The graph below will be created and then can be used directly by Netscape or other browsers that support the PNG file type (most versions do).
Contents of the input file: input1.txt
set output "outfile1.png"; set terminal png color; plot 'temp' with lines;
Use the program "ee" or Electric Eyes to directly view a PNG file since our version of xv does not handle this newer file type. The UNIX utility convert can be used to convert to other file types in batch mode, too.