Graphics | ![]() ![]() |
From the Command Line
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 command to print it to a printer or to a file.
The set Function
The set
function changes the values of properties that control the look of a printed 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 each print of the figure until you change the setting again.
To change the print properties of the current figure, the set
command has the form
set(gcf,'Property1',value1,'Property2',value2,...)
where gcf
is a call that gets 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,
set(gcf,'PaperUnits','centimeters','PaperType','A4',...)
sets the units of measure and the paper size. Changing the Figure's Settings describes commonly used print properties. The Figure Properties reference page contains a complete list of the properties.
You can also use the get
command to retrieve the value of a specific property.
a = get(gcf,'Property')
Note See Changing Session Defaults and "Changing Session-to-Session Defaults" on page 6-25 for more information about managing default property values. |
The print Command
The print
command sends the figure to a printer, saves it to a file, exports it to a graphics-format file, or exports it to the clipboard.
The command and function forms of print
differ slightly in their syntax. Although this document uses the command form, you can easily use the equivalent function form in a program. In both forms, all arguments are optional and can be placed in any order.
print -device -options filename
print('-device','-options','filename')
Note
See Printing the Figure for information about specific
-device and -options values.
|
You control what action the print command takes, depending on the presence or absence of certain arguments. This table describes what arguments to use. The table assumes factory defaults.
![]() | Using Print Dialog Boxes | Changing the Figure's Settings | ![]() |