Printing and Exporting Figures with MATLAB    

Changing Figure Size and Position

This section describes how to set the size and position of the figure to specific values. Depending on the size and orientation of the paper, changing the size or position of the figure can cause it to print off the edges. For more information, see Relationships Among Settings.

Using the Page Setup Dialog Box

  1. Select Page Setup from the figure window's File menu and select the Size and Position tab.
  2. Make sure that the Use manual size and position is checked and that Units is set appropriately.
  3. You can set the width and height of the figure interactively or manually. To set the width and height manually, enter new values in the Width and Height fields or click the arrows to select a new size.
  1. The settings shown for Top, Left, Width, and Height are initialized with MATLAB default values. (This is true even if you resized the figure window by dragging its borders.)

  1. To set the width and height interactively, use the preview image. Use the mouse to drag the edges of the "sample" figure to the desired size.

  2. If you want the figure resized to fill the paper, click Fill page. Note that Fill page may alter the aspect ratio of your image. To get the maximum figure size without altering the aspect ratio, select Fix aspect ratio.
  3. You can set the margins of the figure (offsets from the left and top edges of the paper) interactively or manually. To set the margins manually, enter new values in the Left and Top fields or click the arrows to select a new size.
  1. To set the margins interactively, use the preview image. Use the mouse to drag the "sample" figure to a new position.

  1. To center the figure horizontally and vertically on the paper, click Center
  2. Click OK.

For detailed information about the Size and Position tab of the Page Setup dialog box, see its context sensitive help by clicking its Help button.

Using MATLAB Commands

To print your figure with a specific size, make sure that 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

where:

These are the MATLAB default values for PaperPosition.

This example sets the figure size to a width of 4 and height of 2,

with the origin of the figure positioned two units of measure from the left edge of the paper and one unit of measure from the bottom edge of the paper.

Changing Default Size or Position

If you always want to print or export your figures at a defined size, set the default values for PaperPosition in your startup.m file. For example, this line sets the default size to [0 0 4 3].

If you always want to print or export your figures at the same size as they are on the screen, modify the setting for DefaultFigurePaperPositionMode in your startup.m file as follows


 Size and Position of Printed or Exported Figures Examples