2.4 Directing Where Output Goes

By default, when PyXPlot is used interactively, all plots are displayed on the screen. It is also possible to produce postscript output, to be read into other programs or embedded into LATEX documents, as well as a variety of other graphic formats. The set terminal command is used to specify the output format that is required, and the set output command the file to which output should be directed. For example,

set terminal postscript
set output 'myplot.eps'
plot sin(x)

would produce a postscript plot of $ \sin(x)$ to the file myplot.eps.

The set terminal command can also be used to configure further aspects of the output file format. For example, the following would produce black-and-white and colour output respectively:

set terminal monochrome
set terminal colour

The former is useful for preparing plots for black-and-white publications, the latter for preparing plots for colourful presentations.

Both encapsulated and non-encapsulated postscript can be produced. Following gnuplot's slightly bizarre syntax, the word enhanced is used to produce encapsulated postscript, and noenhanced to produce normal postscript. The former is recommended for producing figures to embed into documents, the latter for plots which are to be printed without further processing:

set terminal noenhanced
set terminal enhanced

It is also possible to produce plots in the gif, png and jpeg graphic formats, as follows:

set terminal gif
set terminal png
set terminal jpg

More than one of the above keywords can be combined on a single line, for example:

set terminal postscript noenhanced colour
set terminal gif monochrome

To return to the default state of displaying plots on screen, the x11 terminal should be selected:

set terminal x11

For more details of the set terminal command, including how to produce transparent gifs and pngs, see section 3.2.

We finally note that, after changing terminals, the replot command is especially useful; it repeats the last plot command.. If any plot items are placed after it, they are added to the last plot.

Dominic Ford 2006-09-09