Chapter 7. Gnuplot

Plotting can be done with gnuplot which is best started from the shell:

$ gnuplot

Try the following sequnce of commands that work on "datafile" created by firstprog in the previous chapter:

gnuplot> plot 'datafile'

gnuplot> plot 'datafile' with linespoints

gnuplot> plot 'datafile', 'datafile' using 1:3

gnuplot> plot 'datafile', sin(x), 'datafile' using 1:3, sin(x/3)

It could seem strange but there is no simple command for writing the figure to the file or to a printer. One actually needs several commands and the common solution is therefore to put things in a file and then load or call that file to perform the desired actions.

gnuplot> call '/Home/guests/olsson/linux-guide/gnuplot/print.gp' file

writes the (encapsulated postscript) figure to the file file.ps (where ps stands for postscript). The postscript file may then e.g. be shown on the screen gv file.ps, sent to the printer, lpr file.ps, or included in a document as discussed in the next chapter.

Help is available with the command help. For further information se the gnuplot tutorial.