Overview of Printing and Exporting

Print and Export Operations

There are four basic operations that you can perform in printing or transferring figures you've created with MATLAB® graphics to specific file formats for other applications to use.




Send a figure from the screen directly to the printer.

Print to File

Write a figure to a PostScript® file to be printed later.

Export to File

Export a figure in graphics format to a file, so that you can import it into an application.

Export to Clipboard

Copy a figure to the Microsoft® Windows® clipboard, so that you can paste it into an application.

Graphical User Interfaces

In addition to typing MATLAB commands, you can use interactive tools for either Microsoft Windows or UNIX® to print and export graphics. The table below lists the GUIs available for doing this and explains how to open them from figure windows.

Dialog Box

How to Open


Print (Windows and UNIX)

File > Print or printdlg function

Send figure to the printer, select the printer, print to file, and several other options

Print Preview

File > Print Preview or printpreview function

View and adjust the final output


File > Export

Export the figure in graphics format to a file

Copy Options

Edit > Copy Options

Set format, figure size, and background color for Copy to Clipboard

Figure Copy Template

File > Preferences

Change text, line, axes, and UI control properties

You can open the Print and Print Preview dialog boxes from a MATLAB file or from the command line with the printdlg and printpreview functions.

Command Line Interface

You can print a MATLAB figure from the command line or from a MATLAB file. Use the print function to specify the output format and start the print or export operation.

    Note:   Printed output from MATLAB commands and Print Previews of it are not guaranteed to duplicate the look of figures on your display screen in every detail. Many factors, including the complexity of the figure, available fonts, and whether a native printer driver or a MATLAB built-in driver to is used, affect the final output and can cause printed output to differ from what you see on your screen.

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.


Print Command

Print a figure to a printer


Print a figure to a file for later printing

print filename

Copy a figure in graphics format to the clipboard on Microsoft Windows systems

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

print -f2 -r600 -depsc spline2d

The functional form of this command is

print('-f2', '-r600', '-depsc', 'spline2d');

Printing on UNIX Platforms without a Display

If you run with the PostScript -nodisplay startup option, or run without the DISPLAY environment variable set, you can use most print options that apply to the UNIX platform, but some restrictions apply. For example, in nodisplay mode uicontrols do not print; thus you cannot print a GUI if you run in this mode.

See Printing and Exporting Without a Display in the documentation for the print function for details.

Specifying Parameters and Options

The table below lists parameters you can modify for the figure to be printed or exported. To change one of these parameters, use the Print Preview or the UNIX Print dialog box, or use the set or print function.

See Change Figure Settings for more detailed instructions.



Figure size

Set size of the figure on printed page

Figure position

Set position of figure on printed page

Paper size

Select printer paper, specified by dimension or type

Paper orientation

Specify way figure is oriented on page

Position mode

Specify figure position yourself or let it be determined automatically

Graphics format

Select format for exported data (e.g., EPS, JPEG)


Specify how finely your figure is to be sampled


Select method (algorithm) for drawing graphics

Renderer mode

Specify the renderer yourself or automatically determine which renderer to use based on the figure's contents

Axes tick marks

Keep axes tick marks and limits as shown or automatically adjust them depending on figure size

Background color

Keep background color as shown on screen or force it to white

Line and text color

Keep line and text objects as shown on screen or print them in black and white

UI controls

Show or hide all user interface controls in figure

Bounding box

Leave space between outermost objects in plot and edges of its background area


Automatically convert RGB values to CMYK values

Character set encoding

Select character set for PostScript printers

Default Settings and How to Change Them

If you have not changed the default print and export settings, MATLAB prints or exports the figure as follows:

  • 8-by-6 inches with no window frame

  • Centered, in portrait format, on 8.5-by-11 inch paper if available

  • Using white background color for the figure and axes

  • Scaling ticks and limits of the axes to accommodate the printed size

Setting Defaults for a Figure

In general, to change the property settings for a specific figure, follow the instructions given in the section Change Figure Settings.

Any settings you change with the Print Preview and Print dialog boxes or with the set function are saved with the figure and affect each printing of the figure until you change the settings again.

The settings you change with the Figure Copy Template Preferences and Copy Options Preferences panels alter the figure as it is displayed on the screen.

Setting Defaults for the Session

You can set the session defaults for figure properties. Set the session default for a property using the syntax


where propertyname is one of the named figure properties. This example sets the paper orientation for all subsequent print operations in the current MATLAB session.


The Figure Properties properties page contains a complete list of the properties.

To see what default properties you can set that will be applied to all subsequent figures in the same MATLAB session, type


To see their current settings, type


Setting Defaults Across Sessions

You can set the session-to-session defaults for figure properties, the print driver, and the print function.

Print Device and Print Command.  Set the default print driver and the default print command in your printopt.m file. This file contains instructions for changing these settings and for displaying the current defaults. Open printopt.m in your editor by typing the command

edit printopt

Scroll down about 40 lines until you come to this comment line:

%---> Put your own changes to the defaults here (if needed)

Add your changes after that line. For example, to change the default driver, first find the line that sets dev, and then replace the text string with an appropriate value. So, to set the default driver to HP® LaserJet III, modify the line to read

dev = '-dljet3';

For the full list of values for dev, see the Drivers section of the print reference page.

    Note   If you set dev to be a graphics format, such as -djpeg, the figure is exported to that type of file rather than being printed.

Figure Properties.  Set the session-to-session default for a property by including commands like the following in your startup.m file:


where propertyname is one of the named figure properties. For example,


keeps the figure background in the screen color.

This is the same command you use to change a session default, except by adding it to your startup.m file, it executes automatically every time you launch MATLAB.

Options you specify in arguments to the print command override properties set using MATLAB commands or the Print Preview dialog box, which in turn override any MATLAB default settings specified in printopt.m or startup.m.

    Note:   To export to vector graphics formats, ensure the figure RendererMode property is set to auto.

Was this topic helpful?