Other tips for fortran users | the gnuplotfortran library which enables direct one-way communication between gnuplot and fortran 95 code
gnuplot is a free plotting program that can plot datafiles and user-defined functions. It can't do everything you might possibly want, but it is very easy to use.
# Gnu population in Antarctica since 1965 1965 103 1970 55 1975 34 1980 24 1985 10You can have as many columns as you like. Comments are indicated by "#".
gnuplotYou can also run gnuplot directly within unix, e.g.
gnuplot < file.gnuwhere file.gnu contains a list of gnuplot commands. This latter option is one you may wish to take up once you know how to use gnuplot.
You can abbreviate commands to save typing.
pop(x) = 103*exp((1965-x)/10)Then we can plot this function, for x from 1960 to 1990, thus:
plot [1960:1990] pop(x)To plot the datafile given above (assuming it is called population.dat)
plot 'population.dat'And to plot both the function and the data
plot [1960:1990] 'population.dat', pop(x)By default, data files are plotted point by point. If you want lines joining the points,
plot 'population.dat' with linespIf you want lines only,
plot 'population.dat' w linesTo control which color each set of lines and points comes out, see help plot. For example, to make the data come out with color 2 (dotted lines), and pop(x) with colour 1,
plot [1960:1990] 'population.dat' w lines 2 2, pop(x) w lines 1 1To plot column 4 of "flib.dat" against column 2 of the same file,
plot "flib.dat" u 2:4 w linesp(this gives column 2 on the x axis and 4 on the y axis). You can also plot points with errorbars. This command plots column 4 versus column 2, with cols 5 and 6 defining the upper and lower error bars
plot "flib.dat" u 2:4:5:6 w errorbars
set term post eps set output "file.eps" replotDon't forget to set the terminal type back to X11 when you are done plotting to the file.
set term X set output
set size 0.6,0.6before plotting to the file. This reduces the size of the graph while keeping the font size, line styles, and point size constant.