Change Figure Settings

Parameters that Affect Printing

The table below shows parameters that you can set before submitting your figure to the printer.

The Parameter column lists all parameters that you can change.

The Default column shows the MATLAB® default setting.

The Dialog Box column shows which dialog box to use to set that parameter. If you can make this setting on only one platform, this is noted in parentheses: (W) for Windows®, and (U) for UNIX®.

Some dialog boxes have tabs at the top to enable you to select a certain category. These categories are denoted in the table below using the format <dialogbox>/<tabname>. For example, Print Preview/Layout... in this column means to use the Print Preview dialog box, selecting the Layout tab.

The print Command or set Property column shows how to set the parameter using the MATLAB print or set function. When using print, the table shows the appropriate command option (for example, print -loose). When using set, it shows the property name to set along with the type of object (for example, (Line) for line objects).

Parameter

Default

Dialog Box

print Command or set Property

Select figure

Last active window

None

print -fhandle

Select printer

System default

Print

print -pprinter

Figure size

8-by-6 inches

Print Preview/Layout

PaperSize (Figure) PaperUnits (Figure)

Position on page

0.25 in. from left, 2.5 in. from bottom

Print Preview/Layout

PaperPosition (Figure) PaperUnits (Figure)

Position mode

Manual

Print Preview/Layout

PaperPositionMode (Figure)

Paper type

Letter

Print Preview/Layout

PaperType (Figure)

Paper orientation

Portrait

Print Preview/Layout

PaperOrientation (Figure)

Renderer

Selected automatically

Print Preview/Advanced

print -painters | -opengl

Renderer mode

Auto

Print Preview/Advanced

RendererMode (Figure)

Resolution

Depends on driver or graphics format

Print Preview/Advanced

print -rresolution

Axes tick marks

Recompute

Print Preview/Advanced

XTickMode, etc. (Axes)

Background color

Force to white

Print Preview/Color

Color (Figure) InvertHardCopy (Figure)

Font size

As in the figure

Print Preview/Lines/Text

FontSize (Text)

Bold font

Regular font

Print Preview/Lines/Text

FontWeight (Text)

Line width

As in the figure

Print Preview/Lines/Text

LineWidth (Line)

Line style

Black or white

Figure Copy Template

LineStyle (Line)

Line and text color

Black and white

Print Preview/Lines/Text

Color (Line, Text)

CMYK color

RGB color

Print Preview/Color (U)

print -cmyk

UI controls

Printed

Print Preview/Advanced

print -noui

Bounding box

Tight

N/A

print -loose

Copy background

Transparent

Copy Options (W)

See "Background color"

Copy size

Same as screen size

Copy Options (W)

See "Figure Size"

Selecting the Figure

By default, the current figure prints. If you have more than one figure open, the current figure is the last one that was active. To make a different figure active, click it to bring it to the foreground.

Using MATLAB Commands

Specify a figure using the command

print -fhandle

This example sends Figure No. 2 to the printer.

print -f2

Selecting the Printer

You can select the printer you want to use with the Print dialog box or with the print function.

Using the Graphical User Interface

  1. Select Print from the figure window's File menu.

  2. Select the printer from the list box near the top of the Print dialog box.

  3. Click OK.

Using MATLAB Commands

You can select the printer using the -P switch of the print function.

This example prints Figure No. 3 to a printer called Calliope.

print -f3 -PCalliope

If the printer name has spaces in it, put single quotation marks around the -P option, as shown here.

print '-Pmy local printer'

    Note:   On Macintosh computers, printer names shown in the print dialog might not work when specified at the command line using the -P option. Use the following command to get the names of the printers you can use with the -P option on your system.

    [~,printers] = findprinters

Using a Network Print Server.  On Windows systems, you can print to a network print server using the form shown here for a printer named trinity located on a computer named PRINTERS.

print -P\\PRINTERS\trinity

    Note:   On Windows platforms, when you use the -P option to identify a printer to use, if you specify any driver other than -dwin or -dwinc, MATLAB output goes to a file with an appropriate extension but does not send it to the printer. You can then copy that file to a printer.

Setting the Figure Size and Position

The default output figure size is 8 inches wide by 6 inches high, which maintains the aspect ratio (width to height) of the MATLAB figure window. The figure's default position is centered both horizontally and vertically when printed to a paper size of 8.5-by-11 inches.

You can change the size and position of the figure:

Using the Graphical User Interface

Select Print Preview from the figure window's File menu to open the Print Preview dialog box. Click the Layout tab to make changes to the size and position of your figure on the printed page.

Use the text edit boxes on the left to enter new dimensions for your figure. Or, use the handlebars on the rulers in the right-hand pane to drag the margins and location of your figure with the mouse. The outer handlebars move the figure toward or away the nearest margin, while the central handlebar repositions the figure on the page without changing its proportions. Guidelines appear while you are using the handlebars.

Settings you can change in the Layout tab are as follows:

Placement.  Choose whether you want the figure to be the same size as it is displayed on your screen, or you want to manually change its size using the options in the Layout pane.

When you select the Use manual size and position mode, type the widths of any of the four margins and the preview image responds after each entry you make. Select units of measure (inches/centimeters/points) with pushbuttons on the Units section on the bottom of the pane.

You can use the four buttons at the bottom of the Placement section to expand the figure to fill the page, make its aspect ratio (ratio of y-extent to x-extent) as printed match that of the figure, center the figure on the page, or restore the setup to what it was when you opened the Print Preview dialog. Selecting Fill page can alter the aspect ratio of your image. To get the maximum figure size without altering the aspect ratio, select Fix aspect ratio.

Auto (actual size, centered).  Select this option to center the figure on the page; it will be the same size as it is in the figure window. The four buttons below the control are dimmed when you select this option.

    Note   Changes you make using Print Preview affect the printed output only. They do not alter the figure displayed on your screen.

Using MATLAB Commands

To print your figure with a specific size or position, make sure the PaperPositionMode property is set to manual (the default). Then set the PaperPosition property to the desired size and position.

The PaperPosition property references a four-element row vector that specifies the position and dimensions of the printed output. The form of the vector is

[left bottom width height]

where

  • left specifies the distance from the left edge of the paper to the left edge of the figure.

  • bottom specifies the distance from the bottom of the paper to the bottom of the figure.

  • width and height specify the figure's width and height.

The default values for PaperPosition are

[0.25 2.5 8.0 6.0]

This example sets the figure size to a width of 4 inches and height of 2 inches, with the origin of the figure positioned 2 inches from the left edge of the paper and 1 inch from the bottom edge.

set(gcf, 'PaperPositionMode', 'manual');
set(gcf, 'PaperUnits', 'inches');
set(gcf, 'PaperPosition', [2 1 4 2]);

    Note   PaperPosition specifies a bottom margin, rather than a top margin as Print Preview does. When you set the top margin using Print Preview, This setting is used to calculate the bottom margin, and updates the PaperPosition property appropriately.

Setting the Paper Size or Type

Set the paper size by specifying the dimensions or by choosing from a list of predefined paper types. If you do not set a paper size or type, the default paper size of 8.5-by-11 inches is used.

Paper-size and paper-type settings are interrelated—if you set a paper type, the paper size also updates. For example, if you set the paper type to US Legal, the width of the paper updates to 8.5 inches and the height to 14 inches.

You can change the paper size and orientation:

Using the Graphical User Interface

Select Print Preview from the figure window's File menu to open the Print Preview dialog box. Click the Layout tab to make changes to the paper type and orientation of the figure on the printed page.

Settings you can change in the Layout tab are as follows:

Paper Format, Units and Orientation.  Select a paper type from the list under Format. If there is no paper type with suitable dimensions, enter your own dimensions in the Width and Height fields. Make sure Units is set appropriately to inches, centimeters, or points. If you change units after setting a paper width and height, the Width and Height fields update to use the units you just selected. The page region in the preview pane updates to show the new paper format or size when you change them.

Use the Orientation buttons to select how you want the figure to be oriented on the printed page. The illustration under Setting the Paper Orientation shows the three types of orientation you can choose from.

    Note   Changes you make using Print Preview affect the printed output only. They do not alter the figure displayed on your screen.

Using MATLAB Commands

Set the PaperType property to one of the built-in MATLAB paper types, or set the PaperSize property to the dimensions of the paper.

When you select a paper type, the unit of measure is not automatically updated. We recommend that you set the PaperUnits property first.

For example, these commands set the units to centimeters and the paper type to A4.

set(gcf, 'PaperUnits', 'centimeters');
set(gcf, 'PaperType', 'A4');

This example sets the units to inches and sets the paper size of 5-by-7 inches.

set(gcf, 'PaperUnits', 'inches');
set(gcf, 'PaperSize', [5 7]);

If you set a paper size for which there is no matching paper type, the PaperType property is automatically set to 'custom'.

Setting the Paper Orientation

Paper orientation refers to how the paper is oriented with respect to the figure. The choices are Portrait (the default), Landscape, and Rotated.

You can change the orientation of the figure:

The figure below shows the same figure printed using the three different orientations.

    Note   The Rotated orientation is not supported by all printers. When the printer does not support it, landscape is used.

Using the Graphical User Interface

  1. Select Print Preview from the figure window's File menu and select the Layout tab. (See Using the Graphical User Interface).

  2. Select the appropriate option button under Orientation.

  3. Click Close.

Using MATLAB Commands

Use the PaperOrientation figure property or the orient function. Use the orient function if you always want your figure centered on the paper.

The following example sets the orientation to landscape:

set(gcf, 'PaperOrientation', 'landscape');

Centering the Figure.  If you set the PaperOrientation property from portrait to either of the other two orientation schemes, you might find that what was previously a centered image is now positioned near the paper's edge. You can either adjust the position (use the PaperPosition property), or you can use the orient function, which always centers the figure on the paper.

The orient function takes the same argument names as PaperOrientation. For example,

orient rotated; 

Selecting a Renderer

A renderer is software and/or hardware that enables MATLAB to display, print, or export a figure. With regard to printing, the renderer determines if the output is a vector or a bitmap format.

For information on specifying the renderer, see these sections:

Supported Renderers

MATLAB supports two rendering methods with the following characteristics:

Painter's

  • Draws figures using vector graphics

  • Generally produces results that scale better and can be edited in application programs designed for this purpose

  • The renderer for creating PostScript®, EPS, PDF, metafile, or SVG files.

OpenGL®

  • Draws figures using bitmap (raster) graphics

  • Generally faster than Painter's

  • Can access graphics rendering hardware available on some systems

  • Avoids possible limitations of Painter's with regard to sorting graphics objects arranged in 3-D views

For more detailed information about changing rendering methods, see the Figure Renderer property.

Manually Set the Renderer

Set the renderer appropriately for the type of output file:

  • Use Painter's for vector format

  • Use OpenGL for bitmap formats

Using the Graphical User Interface

  1. Open the Print Preview dialog box by selecting Print Preview from the figure window's File menu. Select the Advanced tab.

  2. In the Renderer drop-down menu, select the desired rendering method from the list box.

  3. Click Close.

Using MATLAB Commands

You can use the Renderer property or a switch with the print function to set the renderer for printing or exporting. These two lines each set the renderer for the current figure to painters.

set(gcf,'Renderer','painters');

or

print -painters

The first example saves the new value of Renderer with the figure. The second example affects only the current print or export operation.

Renderer Selection

When you export a figure to a graphics file format, MATLAB selects the renderer based on whether the output file type is a vector or bitmap format. However, MATLAB can change the renderer only if the RendererMode property is set to auto.

If you are exporting to a vector format, MATLAB uses the painters renderer in most cases, which results in true vector graphics that can be edited more easily in other applications.

Setting the Resolution

Resolution refers to how accurately your figure is rendered when printed or exported. Higher resolutions produce higher quality output. The specific definition of resolution depends on whether your figure is output as a bitmap or as a vector graphic.

You can change the resolution used to print a figure:

Default Resolution and When You Can Change It

The default resolution depends on the renderer used and the graphics format or printer driver specified. The following two tables summarize the default resolutions and whether you can change them.

Resolutions Used with Graphics Formats

Graphics Format

Default Resolution

Can Be Changed?

Built-in MATLAB export formats, (except for EMF and EPS)

150 dpi (always use OpenGL)

Yes

EMF export format (Enhanced Metafile)

150 dpi

Yes

EPS (Encapsulated PostScript)

150 dpi, if OpenGL; 864 dpi if Painter's

Yes

Resolutions Used with Printer Drivers

Printer Driver

Default Resolution

Can Be Changed?

Windows and PostScript drivers

150 dpi, if OpenGL; 864 dpi if Painter's

Yes

Choosing a Setting

You might need to determine your resolution requirements through experimentation, but you can also use the following guidelines.

For Printing.  The default resolution of 150 dpi is normally adequate for typical laser-printer output. However, if you are preparing figures for high-quality printing, such as a textbook or color brochures, you might want to use 200 or 300 dpi. The resolution you can use can be limited by the printer's capabilities.

For Exporting.  If you are exporting your figure, base your decision on the resolution supported by the final output device. For example, if you will import your figure into a word processing document and print it on a printer that supports a maximum resolution setting of 300 dpi, you could export your figure using 300 dpi to get a precise one-to-one correspondence between pixels in the file and dots on the paper.

    Note   The only way to set resolution when exporting is with the print function.

Impact of Resolution on Size and Memory Needed

Resolution affects file size and memory requirements. For both printing and exporting, the higher the resolution setting, the longer it takes to render your figure.

Using the Graphical User Interface

To set the resolution for built-in MATLAB printer drivers:

  1. From the Print dialog box, click Properties. This opens a new dialog box. (This box can differ from one printer to another.)

  2. You may be able to set the resolution from this dialog. If not, then click Advanced to get to a dialog box that enables you to do this.

  3. Set the resolution, and then click OK. (The resolution setting might be labeled by another name, such as "Print Quality.")

Using MATLAB Commands

If you use a Windows printer driver, you can only set the resolution using the Windows Document Properties dialog box.

Otherwise, to set the resolution for printing or exporting, the syntax is

print -rnumber

where number is the number of dots per inch. To print or export a figure using screen resolution, set number to 0 (zero).

This example prints the current figure with a resolution of 100 dpi:

print -r100

This example exports the current figure to a TIFF file using screen resolution:

print -r0 -dtiff myfile.tif

Setting the Axes Ticks and Limits

The default output size, 8-by-6 inches, is normally larger than the screen size. If the size of your printed or exported figure is different from its size on the screen, the number and placement of axes tick marks scale to suit the output size. This section shows you how to lock them so that they are the same as they were when displayed.

You can change the resolution used when printing a MATLAB figure:

Using the Graphical User Interface

Select Print Preview from the figure window's File menu to open the Print Preview dialog box. Select the Advanced tab to make changes to the axes, UI controls, or renderer settings.

Settings you can change in the Advanced tab are as follows, by panel:

Axes limits and ticks.  If the size of your printed or exported figure is different from its size on the screen, the number and placement of axes tick marks scale to suit the output size. Select Keep screen limits and ticks to lock them so that they are the same as they were when displayed. If you want to automatically adjust the ticks and limits when scaling for printing, select Recompute limits and ticks.

Miscellaneous.  Use the Renderer drop-down menu to specify which renderer to use in printing the figure. Set the renderer to Painters, or OpenGL, or select auto to automatically decide which one to use, depending on the characteristics of the figure. (See Selecting a Renderer).

Use the Resolution drop-down menu to specify the resolution, in dots per inch (DPI), at which to render and print the figure. You can select 150, 300, or 600 DPI, or type in a different value (positive integer).

Figure UI Controls.  By default, user interface controls are included in your printed or exported figure. Clear the Print UIControls check box to exclude them. (See Excluding User Interface Controls from Printed Output).

    Note   Changes you make using Print Preview affect the printed output only. They do not alter the figure displayed on your screen.

Using MATLAB Commands

To set the XTickMode, YTickMode, and ZTickMode properties to manual, type

set(gca,'XTickMode','manual')
set(gca,'YTickMode','manual')
set(gca,'ZTickMode','manual')

Setting the Background Color

You can keep the background the same as is shown on the screen when printed, or change the background to white. There are two types of background color settings in a figure: the axes background and the figure background. The default displayed color of both backgrounds is gray, but you can set them to any of several colors.

Regardless of the background colors in your displayed figure, by default, they are always changed to white when you print or export. This section shows you how to retain the displayed background colors in your output.

Using the Graphical User Interface

To retain the background color on a per figure basis:

  1. Open the Print Preview dialog box by selecting Print Preview from the figure window's File menu. Select the Color tab.

  2. Select Same as figure.

  3. Click Close.

If you are exporting your figure using the clipboard, use the Copy Options panel of the Preferences dialog box.

Using MATLAB Commands

To retain your background colors, use

set(gcf,'InvertHardCopy','off');

The following example sets the figure background color to blue, the axes background color to yellow, and then sets InvertHardCopy to off so that these colors appear in your printed or exported figure.

set(gcf,'color','blue');
set(gca,'color','yellow');
set(gcf,'InvertHardCopy','off');

Setting Line and Text Characteristics

If you transfer your figures to Microsoft® Word or PowerPoint® applications, you can set line and text characteristics to values recommended for those applications. The Figure Copy Template Preferences dialog box provides Word and PowerPoint options to make these settings, or you can set certain line and text characteristics individually.

You can change line and text characteristics:

Using the Graphical User Interface

To open Figure Copy Template Preferences, select Preferences from the File menu, and then click Figure Copy Template in the left pane.

Settings you can change in the Figure Copy Template Preferences dialog box are as follows:

Microsoft Word or PowerPoint.  Click Documents or Presentations to apply recommended MATLAB settings.

Text.  Use options under Text to modify the appearance of all text in the figure. You can change the font size, change the text color to black and white, and change the font style to bold.

Lines.  Use the Lines options to modify the appearance of all lines in the figure:

  • Custom width — Change the line width.

  • Change style (Black or white) — Change colored lines to black or white.

  • Change style (B&W styles) — Change solid lines to different line styles (e.g., solid, dashed, etc.), and black or white color.

UIControls and axes.  If your figure includes user interface controls, you can choose to show or hide them by clicking Show uicontrols. Also, to keep axes limits and tick marks as they appear on the screen, click Keep axes limits and tick spacing. To allow automatic scaling of axes limits and tick marks based on the size of the printed figure, clear this box.

    Note   Changes you make using Print Preview affect the printed output only. They do not alter the figure displayed on your screen.

Using MATLAB Commands

You can use the set function on selected graphics objects in your figure to change individual line and text characteristics.

For example, to change line width to 1.8 and line style to a dashed line, use

lineobj = findobj('Type','line');
set(lineobj,'LineWidth',1.8);
set(lineobj,'LineStyle','--');

To change the font size to 15 points and font weight to bold, use

textobj = findobj('Type','text');
set(textobj,'FontUnits','points');
set(textobj,'FontSize',15);
set(textobj,'FontWeight','bold');

Setting the Line and Text Color

When colored lines and text are dithered to gray by a black-and-white printer, it does not produce good results for thin lines and the thin lines that make up text characters. You can, however, force all line and text objects in the figure to print in black and white, thus improving their appearance in the printed copy. When you select this setting, the lines and text are printed all black or all white, depending on the background color.

The default is to leave lines and text in the color that appears on the screen.

    Note   Your background color might not be the same as what you see on the screen. See the Color tab for an option that preserves the background color when printing.

You can change the resolution used to print a figure:

Using the Graphical User Interface

Select Print Preview from the figure window's File menu to open the Print Preview dialog box. Select the Lines and Text tab to make changes to the color of all lines and text on the printed page. The controls for the Lines and Text tab are shown below:

Settings you can change in Lines and Text are as follows:

Lines.  The default option in this panel causes lines to print at the same width they are portrayed in the figure window. You can scale line width from 0 percent upwards for printing using the Scale By field. To print lines at a particular point size, select Custom. All lines on the plot will be the same weight when you use the Custom option; the Scale By option respects relative line weight.

When you scale lines downward, you can prevent them from becoming too faint by setting the Min Width option to Custom and specifying a minimum line width in points in that field.

Text.  The default is to print text in the same font and at the same size as it is in the figure. To change the font (for all text) select Custom and choose a new font from the drop-down list that is then enabled. Scale the font size using the Scale By option. To print text at a particular point size, select Custom. All text on the plot will be printed at the point size you specify when you use the Custom option; the Scale By option respects relative font size. You can specify the Font Weight (normal, light, demi, or bold) and Font Angle (normal, italic, or oblique) for all text as well, using the drop-down menus at the bottom of the Text panel.

Header.  Type any text that you want to appear at the top of the printed figure in the Header Text edit field. If you want today's date and/or time appended to the header text, select the appropriate format from the Date Style popup menu. To specify and style the header font (which is independent of the font used in the figure), click the Font button and choose a font name, size, and style from the Font selection window that appears.

    Note   Changes you make using Print Preview affect the printed output only. They do not alter the figure displayed on your screen.

Using MATLAB Commands

There is no equivalent MATLAB command that sets line and text color depending on background color. Set the color of lines and text using the set function on either line or text objects in your figure.

This example sets all lines and text to black:

set(findobj('Type','line'),'Color','black');
set(findobj('Type','text'),'Color','black');

Specifying a Colorspace for Printing and Exporting

By default, color output is in the RGB color space (red, green, blue). If you plan to publish and print MATLAB figures using printing industry standard four-color separation, you might want to use the CMYK color space (cyan, magenta, yellow, black).

Using the Windows Graphical User Interface

Select Print Preview from the figure window's File menu to open the Print Preview dialog box. Select the Color tab to make changes to the color of all lines and text on the printed page. The controls for the Color tab are shown below:

You can print the contents of your figure in color, grayscale, or black-and-white by selecting the appropriate button in the panel. When you select Color, you can choose between an RGB (red/green/blue) or a CMYK (cyan/magenta/yellow/black) color specification, if your printer is capable of it.

Independently of the Color Scale controls, you can specify a Background color for printing. Select Same as figure to use the color used in the figure itself (default is gray), or specify a Custom color from the combo box popup menu. The choices are black, white, and several RGB color triplet values; you type any valid MATLAB colorspec in this field as well, such as g, magenta, or .3 .4 .5.

The background color you specify is respected even if you choose Black and White or Gray Scale in the Color Scale panel.

Using the Graphical User Interface on UNIX Platforms

  1. Select Print from the figure window's File menu.

  2. Click the Appearance tab.

  3. In the Color Appearance panel, select Color.

  4. Click Print.

On any platform, you can also indicate whether to print in color, grayscale or black-and-white with the Print Preview dialog box.

Using MATLAB Commands

Use the -cmyk option with the print function. This example prints the current figure in CMYK using a PostScript Level II color printer driver.

print -dpsc2 -cmyk

Excluding User Interface Controls from Printed Output

User interface controls are objects that you create and add to a figure. For example, you can add a button to a figure that, when clicked, conveniently runs another MATLAB file. By default, user interface controls are included in your printed or exported figure. This section shows how to exclude them.

Using the Graphical User Interface

  1. Open the Print Preview dialog box by selecting Print Preview from the figure window's File menu, and then select the Advanced tab.

  2. Under Miscellaneous, clear the Print UIControls check box.

  3. Click Close.

Using MATLAB Commands

Use the -noui switch. This example specifies a color PostScript driver and excludes UI controls.

print -dpsc -noui

This example exports the current figure to a color EPS file and excludes UI controls.

print -depsc -noui myfile.eps

Producing Uncropped Figures

In most cases, MATLAB crops the background tightly around the objects in the figure. Depending on the printer driver or file format you use, you might be able to produce uncropped output. An uncropped figure has increased background area and is often desirable for figures that contain UI controls.

The setting you make changes the PostScript BoundingBox property saved with the figure.

Using MATLAB Commands

Use the -loose option with the print function. On Windows platforms, the uncropped option is only available if you print to a file.

This example exports the current figure, uncropped, to an EPS file.

print -deps -loose myfile.eps
Was this topic helpful?