2.7 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 graphical formats. The set terminal command1 is used to specify the output format that is required, and the set output command is used to specify the file to which output should be directed. For example,

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

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

The set terminal command can also be used to configure various output options within each supported file format. For example, the following commands would produce black-and-white or 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. The former is recommended for producing figures to embed into documents, the latter for plots which are to be printed without further processing. The postscript terminal produces the latter; the eps terminal should be used to produce the former. Similarly the pdf terminal produces files in the portable document format (pdf) read by Adobe Acrobat:

set terminal postscript
set terminal eps
set terminal pdf

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 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 gif and png images with transparent backgrounds, see Section 3.4.

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 pre-existing plot.

Footnotes

  1. Gnuplot users should note that the syntax of the set terminal command in PyXPlot is somewhat different from that which they are used to; see Section 3.4.