Next: , Previous: , Up: High-Level Plotting   [Contents][Index]

15.2.8 Printing and Saving Plots

The print command allows you to send plots to you printer and to save plots in a variety of formats. For example,

print -dpsc

prints the current figure to a color PostScript printer. And,

print -deps foo.eps

saves the current figure to an encapsulated PostScript file called foo.eps.

Function File: print ()
Function File: print (options)
Function File: print (filename, options)
Function File: print (h, filename, options)

Print a plot, or save it to a file.

Both output formatted for printing (PDF and PostScript), and many bitmapped and vector image formats are supported.

filename defines the name of the output file. If the file name has no suffix, one is inferred from the specified device and appended to the file name. If no filename is specified, the output is sent to the printer.

h specifies the handle of the figure to print. If no handle is specified the current figure is used.

For output to a printer, PostScript file, or PDF file, the paper size is specified by the figure’s papersize property. The location and size of the image on the page are specified by the figure’s paperposition property. The orientation of the page is specified by the figure’s paperorientation property.

The width and height of images are specified by the figure’s paperpositon(3:4) property values.

The print command supports many options:


Specify the handle, h, of the figure to be printed. The default is the current figure.


Set the printer name to which the plot is sent if no filename is specified.


Specify the command for calling Ghostscript. For Unix and Windows the defaults are "gs" and "gswin32c", respectively.


Color or monochrome output.


Force all lines to be solid or dashed, respectively.


Specify the orientation of the plot for printed output. For non-printed output the aspect ratio of the output corresponds to the plot area defined by the "paperposition" property in the orientation specified. This option is equivalent to changing the figure’s "paperorientation" property.


Octave is able to produce output for various printers, bitmaps, and vector formats by using Ghostscript. For bitmap and printer output anti-aliasing is applied using Ghostscript’s TextAlphaBits and GraphicsAlphaBits options. The default number of bits for each is 4. Allowed values for N are 1, 2, or 4.


The available output format is specified by the option device, and is one of:


PostScript (level 1 and 2, mono and color). The FLTK graphics toolkit generates PostScript level 3.0.


Encapsulated PostScript (level 1 and 2, mono and color). The FLTK graphic toolkit generates PostScript level 3.0.


Generate a LaTeX (or TeX) file for labels and eps/ps/pdf for graphics. The file produced by epslatexstandalone can be processed directly by LaTeX. The other formats are intended to be included in a LaTeX (or TeX) document. The tex device is the same as the epslatex device. The pdflatex device is only available for the FLTK graphics toolkit.


Generate a LaTeX file using PGF/TikZ. For the FLTK toolkit the result is PGF.


Adobe Illustrator (Obsolete for Gnuplot versions > 4.2)






Microsoft Enhanced Metafile


XFig. For the Gnuplot graphics toolkit, the additional options -textspecial or -textnormal can be used to control whether the special flag should be set for the text in the figure. (default is -textnormal)


HP plotter language




Portable network graphics


JPEG image


GIF image (only available for the Gnuplot graphics toolkit)




Scalable vector graphics


Portable document format

If the device is omitted, it is inferred from the file extension, or if there is no filename it is sent to the printer as PostScript.


Additional devices are supported by Ghostscript. Some examples are;


HP LaserJet IIP


HP LaserJet III


HP DeskJet and DeskJet Plus


HP DeskJet 550C


HP PointJet


24-bit color PCX file format


Portable Pixel Map file format


Produces pdf output from eps

For a complete list, type system ("gs -h") to see what formats and devices are available.

When Ghostscript output is sent to a printer the size is determined by the figure’s "papersize" property. When the output is sent to a file the size is determined by the plot box defined by the figure’s "paperposition" property.


Append PostScript or PDF output to a pre-existing file of the same type.


Resolution of bitmaps in pixels per inch. For both metafiles and SVG the default is the screen resolution; for other formats it is 150 dpi. To specify screen resolution, use "-r0".


Force a tight or loose bounding box for eps files. The default is loose.


Add a preview to eps files. Supported formats are:


Provide an interchange preview.


Provide a metafile preview.


Provide pict preview.


Provide a tiff preview.


Plot size in pixels for EMF, GIF, JPEG, PBM, PNG, and SVG. For PS, EPS, PDF, and other vector formats the plot size is in points. This option is equivalent to changing the size of the plot box associated with the "paperposition" property. When using the command form of the print function you must quote the xsize,ysize option. For example, by writing "-S640,480".


Use fontname and/or fontsize for all text. fontname is ignored for some devices: dxf, fig, hpgl, etc.

The filename and options can be given in any order.

Example: Print to a file using the svg device.

figure (1);
clf ();
surf (peaks);
print -dsvg figure1.svg

Example: Print to an HP DeskJet 550C.

clf ();
surf (peaks);
print -dcdj550

See also: saveas, orient, figure.

Function File: saveas (h, filename)
Function File: saveas (h, filename, fmt)

Save graphic object h to the file filename in graphic format fmt.

fmt should be one of the following formats:




Encapsulated PostScript


JPEG Image


PNG Image


Enhanced Meta File


Portable Document Format

All device formats specified in print may also be used. If fmt is omitted it is extracted from the extension of filename. The default format is "pdf".

clf ();
surf (peaks);
saveas (1, "figure1.png");

See also: print, orient.

Function File: orient (orientation)
Function File: orient (hfig, orientation)
Function File: orientation = orient ()
Function File: orientation = orient (hfig)

Query or set the print orientation for figure hfig.

Valid values for orientation are "portrait", "landscape", and "tall".

The "landscape" option changes the orientation so the plot width is larger than the plot height. The "paperposition" is also modified so that the plot fills the page, while leaving a 0.25 inch border.

The "tall" option sets the orientation to "portrait" and fills the page with the plot, while leaving a 0.25 inch border.

The "portrait" option (default) changes the orientation so the plot height is larger than the plot width. It also restores the default "paperposition" property.

When called with no arguments, return the current print orientation.

If the argument hfig is omitted, then operate on the current figure returned by gcf.

See also: print, saveas.

Next: , Previous: , Up: High-Level Plotting   [Contents][Index]