#### 15.2.9 Printing and Saving Plots

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

         print -deps foo.eps

writes 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 graph, or save it to a file

> filename defines the file 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 figure handle. If no handle is specified the handle for the current figure is used.

> options:

> `-f` h
>   Specify the handle, h, of the figure to be printed. The default is the current figure.
> `-P` printer
>   Set the printer name to which the graph is sent if no filename is specified.
> `-G` ghostscript_command
>   Specify the command for calling Ghostscript. For Unix and Windows, the defaults are 'gs' and 'gswin32c', respectively.
> `-color`
> `-mono`
>   Monochrome or color output.
> `-solid`
> `-dashed`
>   Forces all lines to be solid or dashed, respectively.
> `-portrait`
> `-landscape`
>   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 options is equivalent to changing the figure's "paperorientation" property.
> `-d` device
>   Output device, where device is one of:
>   `ps`
>   `ps2`
>   `psc`
>   `psc2`
>     Postscript (level 1 and 2, mono and color). The FLTK graphics toolkit generates Postscript level 3.0.
>   `eps`
>   `eps2`
>   `epsc`
>   `epsc2`
>     Encapsulated postscript (level 1 and 2, mono and color). The FLTK graphic toolkit generates Postscript level 3.0.
>   `tex`
>   `epslatex`
>   `epslatexstandalone`
>   `pstex`
>   `pslatex`
>   `pdflatex`
>     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.
>   `tikz`
>     Generate a LaTeX file using PGF/TikZ. For the FLTK the result is PGF.
>   `ill`
>   `aifm`
>     Adobe Illustrator (Obsolete for Gnuplot versions > 4.2)
>   `cdr`
>   `corel`
>     CorelDraw
>   `dxf`
>     AutoCAD
>   `emf`
>   `meta`
>     Microsoft Enhanced Metafile
>   `fig`
>     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`).
>   `hpgl`
>     HP plotter language
>   `mf`
>     Metafont
>   `png`
>     Portable network graphics
>   `jpg`
>   `jpeg`
>     JPEG image
>   `gif`
>     GIF image (only available for the Gnuplot graphics toolkit)
>   `pbm`
>     PBMplus
>   `svg`
>     Scalable vector graphics
>   `pdf`
>     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.

> `-d` ghostscript_device
>   Additional devices are supported by Ghostscript. Some examples are;
>   `ljet2p`
>     HP LaserJet IIP
>   `ljet3`
>     HP LaserJet III
>   `deskjet`
>     HP DeskJet and DeskJet Plus
>   `cdj550`
>     HP DeskJet 550C
>   `paintjet`
>     HP PointJet
>   `pcx24b`
>     24-bit color PCX file format
>   `ppm`
>     Portable Pixel Map file format
>   `pdfwrite`
>     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`
>   Appends the PS, or PDF output to a pre-existing file of the same type.
> `-r` NUM
>   Resolution of bitmaps in pixels per inch. For both metafiles and SVG the default is the screen resolution, for other it is 150 dpi. To specify screen resolution, use "-r0".
> `-tight`
>   Forces a tight bounding box for eps-files.
> `-`preview
>   Adds a preview to eps-files. Supported formats are;
>   `-interchange`
>     Provides an interchange preview.
>   `-metalfile`
>     Provides a metafile preview.
>   `-pict`
>     Provides pict preview.
>   `-tiff`
>     Provides a tiff preview.
> `-S` xsize`,`ysize
>   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 "paperposition" property. Using the command form of the print function, you must quote the xsize,ysize option. For example, by writing `"-S640,480"`.
> `-F` fontname
> `-F` fontname`:`size
> `-F:`size
>   Associates all text with the fontname and/or fontsize. 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.

>               figure (1);
>               clf ();
>               surf (peaks);
>               print -dcdj550

> See also: figure, orient, saveas.

— 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:

> `ps`
>   Postscript
> `eps`
>   Encapsulated Postscript
> `jpg`
>   JPEG Image
> `png`
>   PNG Image
> `emf`
>   Enhanced Meta File
> `pdf`
>   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.

— Function File: orient (orientation)

> Set the default print orientation. Valid values for orientation include `"landscape"`, `"portrait"`, and `"tall"`.

> The `"tall"` option sets the orientation to portait and fills the page with the plot, while leaving a 0.25in border.

> If called with no arguments, return the default print orientation.