Next: , Previous: plot, Up: plot

3.1 How to use plot

The GNU plot filter plot displays GNU graphics metafiles or translates them to other formats. It will take input from files specified on the command line or from standard input. The ‘-T’ option is used to specify the desired output format. Supported output formats include "X", "png", "pnm", "gif", "svg", "ai", "ps", "cgm", "fig", "pcl", "hpgl", "regis", "tek", and "meta" (the default).

The metafile format is a device-independent format for storage of vector graphics. By default, it is a binary rather than a human-readable format (see Metafiles). Each of the graph, pic2plot, tek2plot, and plotfont utilities will write a graphics metafile to standard output if no ‘-T’ option is specified on its command line. The GNU libplot graphics library may also be used to produce metafiles. Metafiles may contain arbitrarily many pages of graphics, but each metafile produced by graph contains only a single page.

plot, like the metafile format itself, is useful if you wish to preserve a vector graphics file, and display or edit it with more than one drawing editor. The following example shows how you may do this.

To produce a plot of data arranged as alternating x and y coordinates in an ASCII file, you may use graph as follows:

     graph < datafile > test.meta

The file test.meta will be a single-page graphics metafile. Similarly, to create in metafile format a plot consisting of a simple figure, you may do:

     echo 0 0 1 1 2 0 | spline | graph > test.meta

To display any such plot on an X Window System display, you would do

     plot -T X test.meta


     plot -T X < test.meta

To print the plot on a Postscript printer, you would do something like

     plot -T ps < test.meta | lpr

To edit it with the free idraw drawing editor, you would do

     plot -T ps < test.meta >

To produce a PNG file, you would do

     plot -T png < test.meta > test.png

To produce a “portable anymap” (a file in PBM, PGM, or PPM format, whichever is most appropriate) you would do

     plot -T pnm < test.meta > test.pnm

and to produce a pseudo-GIF file, you would do

     plot -T gif < test.meta > test.gif

Similarly, to produce versions of the plot in SVG format and WebCGM format that can be displayed in a Web browser with SVG and WebCGM support, you would do

     plot -T svg < test.meta > test.svg
     plot -T cgm < test.meta > test.cgm

To produce a version of the plot that can be viewed and edited with Adobe Illustrator, you would do

     plot -T ai < test.meta >

and to produce a version that can be viewed and edited with the free xfig drawing editor, you would do

     plot -T fig < test.meta > test.fig
     xfig test.fig

Other formats may be obtained by using plot -T pcl, plot -T hpgl, plot -T regis, and plot -T tek.

plot may behave differently depending on the environment in which it is invoked. In particular, plot -T svg, plot -T ai, plot -T ps, plot -T cgm, plot -T fig, plot -T pcl, and plot -T hpgl are affected by the environment variable PAGESIZE. plot -T X, plot -T png, plot -T pnm, and plot -T gif are affected by the environment variable BITMAPSIZE. The DISPLAY environment variable affects the operation of plot -T X, and the TERM environment variable affects the operation of plot -T tek. There are also several environment variables that affect the operation of plot -T pcl and plot -T hpgl. For a complete discussion of the effects of the environment on plot, see plot Environment.