How to use gnuplot (gnu1)
How to use gnuplot
gnuplot is a public domain plotting program from the Free Software Foundation.
It runs on most systems, except of Macintosh, which is boycotted by the FSF.
It is a powerful program, among other things it produces very good
postscript
files, which can be used in the LaTeX files.
Special information:
Gnuplot Task 1........
Gnuplot Task 2
Gnuplot Task 3........
Gnuplot Task 4........
Functions in Gnuplot (and Fit)
CALL: gnuplot
opens the command line interface
usually anounces the standard terminal driver
On the first 'plot' command opens the graphical window
About postscript, see below
There is a number of examples in the working directory. Most important commands:
To load a prepared file of commands: load "probabs.com"
To plot a set of data from a file : plot "probabs"
plot "probabs" using 1,4
plot "probabs" using 1,4 with lines
When you change for example xrange (clear meaning, set xrange [0:6],
you can redraw the picture by replot or rep.
There is a very good help system. Type help to start learning.
Now we copy a command set, illustrating use of USER-DEFINED constants and functi
ons:
----------
# This script demonstrates user defined variables
# and user defined functions
a=7 # user defined
d=3 # user defined
f(x)=a*exp(-d*x*x) # user defined
set xrange [-2:2]
set yrange [0:a]
plot f(x)
----------
You can paste this directly as an input under gnuplot. The sign '#' starts a c
ommand
You can redefine a constant any time later. This can be used for visual fitting.
------------
# Example of visual fitting:
----------
a=0.325
plot "data",f(x)
a=0.350
replot
a=0.375
rep
----------
until you have found a good value of a.
To copy the existing picture to a PostScript file:
(To produce an encapsulated postscript file)
--------------
set terminal postscript eps monochrome "Courier" 18
set output "fiename.eps" # otherwise writes the postscript into the screen
set size 1.8,1 # for plots which have a long x-axis
replot
set terminal x11 # closes fiename.eps and comes back to X11
replot
--------------
Index