Graphics    

Command Line Interface

You can print a MATLAB figure from the command line or from a program. Use the set function to set the properties that control how the printed figure looks. Use the print function to start the print or export operation.

Modifying Properties with set

The set function changes the values of properties that control the look of a figure. These properties are stored with the figure. When you change one of the properties, the new value is saved with the figure and affects the look of the figure each time you print it until you change the setting again.

To change the print properties of the current figure, the set command has the form

where gcf is a call that returns the handle of the current figure, and each property-value pair consists of a named property followed by the value to which the property is set.

For example,

sets the units of measure and the paper size. Changing a Figure's Settings describes commonly used print properties. The Figure Properties reference page contains a complete list of the properties.

Examining Properties with get

You can also use the get function to retrieve the value of a specific property.

Printing and Exporting with print

The print function performs any of the four actions shown in the table below. You control what action is taken, depending on the presence or absence of certain arguments.

Action
Print Command
Print a figure to a printer
print
Print a figure to a file for later printing
print filename
Copy a figure in graphics format to the clipboard
print -dfileformat
Export a figure to a graphics format file that you can later import into an application
print -dfileformat filename

You can also include optional arguments with the print command. For example, to export Figure No. 2 to file spline2d.eps, with 600 dpi resolution, and using the EPS color graphics format, use

The functional form of this command is


  Overview of Printing and Exporting Specifying Parameters and Options