Documentation Center

  • Trial Software
  • Product Updates

Printing and Exporting Use Cases

Printing a Figure at Screen Size

By default, your figure prints at 8-by-6 inches. This size includes the area delimited by the background. This example shows how to print or export your figure the same size it is displayed on your screen.

Using the Graphical User Interface

  1. Resize your figure window to the size you want it to be when printed.

  2. Select Print Preview from the figure window's File menu, and select the Layout tab.

  3. In the Placement panel, select Auto (Actual Size, Centered).

  4. Click Print in the upper right corner to print the figure.

  5. The Print dialog box opens for you to print the figure.

Using MATLAB Commands

Set the PaperPositionMode property to auto before printing the figure.

set(gcf, 'PaperPositionMode', 'auto');
print

If later you want to print the figure at its original size, set PaperPositionMode back to 'manual'.

Printing with a Specific Paper Size

The MATLAB® default paper size is 8.5-by-11 inches. This example shows how to change the paper size to 8.5-by-14 inches by selecting a paper type (Legal).

Using the Graphical User Interface

  1. Select Print Preview from the figure window's File menu, and select the Layout tab.

  2. Select the Legal paper type from the list in the Paper panel. The Width and Height fields update to 8.5 and 14, respectively.

  3. Make sure that Units is set to inches.

  4. Click Print in the upper right corner to print the figure.

  5. The Print dialog box opens for you to print the figure.

Using MATLAB Commands

Set the PaperUnits property to inches and the PaperType property to Legal.

set(gcf, 'PaperUnits', 'inches');
set(gcf, 'PaperType', 'Legal');

Alternatively, you can set the PaperSize property to the size of the paper, in the specified units.

set(gcf, 'PaperUnits', 'inches');
set(gcf, 'PaperSize', [8.5 14]);

Printing a Centered Figure

This example sets the size of a figure to 5.5-by-3 inches and centers it on the paper.

Using the Graphical User Interface

  1. Select Print Preview from the figure window's File menu, and select the Layout tab.

  2. Make sure Use manual size and position is selected.

  3. Enter 5.5 in the Width field and 3 in the Height field.

  4. Make sure that Units field is set to inches.

  5. Click Center.

  6. Click OK.

  7. Click Print to open the Print dialog box and print the figure.

Using MATLAB Commands

  1. Start by setting PaperUnits to inches.

    set(gcf, 'PaperUnits', 'inches')
  2. Use PaperSize to return the size of the current paper.

    papersize = get(gcf, 'PaperSize')
    
    papersize =
                  8.5000   11.0000
  3. Initialize variables to the desired width and height of the figure.

    width = 5.5;         % Initialize a variable for width.
    height = 3;          % Initialize a variable for height.
  4. Calculate a left margin that centers the figure horizontally on the paper. Use the first element of papersize (width of paper) for the calculation.

    left = (papersize(1)- width)/2
    
    left =
              1.5000
  5. Calculate a bottom margin that centers the figure vertically on the paper. Use the second element of papersize (height of paper) for the calculation.

    bottom = (papersize(2)- height)/2
    
    bottom =
              4
  6. Set the figure size and print.

    myfiguresize = [left, bottom, width, height];
    set(gcf, 'PaperPosition', myfiguresize);
    print

Exporting in a Specific Graphics Format

Export a figure to a graphics-format file when you want to import it at a later time into another application such as a word processor.

Using the Graphical User Interface

  1. Select Save As from the figure window's File menu.

  2. Use the Save in field to navigate to the folder in which you want to save your file.

  3. Select a graphics format from the Save as type list.

  4. Enter a filename in the File name field. An appropriate file extension, based on the format you chose, is displayed.

  5. Click Save to export the figure.

Using MATLAB Commands

From the command line, you must specify the graphics format as an option. See the print reference page for a complete list of graphics formats and their corresponding option strings.

This example exports a figure to an EPS color file, myfigure.eps, in your current folder.

print -depsc myfigure

This example exports Figure No. 2 at a resolution of 300 dpi to a 24-bit JPEG file, myfigure.jpg.

print -djpeg -f2 -r300 myfigure

This example exports a figure at screen size to a 24-bit TIFF file, myfigure.tif.

set(gcf, 'PaperPositionMode', 'auto')   % Use screen size
print -dtiff myfigure

Exporting in EPS Format with a TIFF Preview

Use the print function to export a figure in EPS format with a TIFF preview. When you import the figure, the application can display the TIFF preview in the source document. The preview is color if the exported figure is color, and black and white if the exported figure is black and white.

This example exports a figure to an EPS color format file, myfigure.eps, and includes a color TIFF preview.

print -depsc -tiff myfigure

This example exports a figure to an EPS black-and-white format file, myfigure.eps, and includes a black-and-white TIFF preview.

print -deps -tiff myfigure

Exporting a Figure to the Clipboard

Export a figure to the clipboard in graphics format when you want to paste it into another Windows® or Macintosh application such as a word processor.

Using the Graphical User Interface

This example exports a figure to the clipboard in enhanced metafile (EMF) format. Figure settings are chosen that would make the exported figure suitable for use in a Microsoft® Word or PowerPoint® slide. Changing the settings modifies the figure displayed on the screen.

  1. Create a figure containing text. You can use the following code.

    x = -pi:0.01:pi; 
    h = plot(x, sin(x));
    title('Sine Plot');
    
  2. Select Preferences from the figure File menu. Then select Figure Copy Template from the Preferences dialog box.

  3. In the Figure Copy Template Preferences panel, click the PowerPoint button. The suggested settings for PowerPoint are added to the template.

  4. In the Lines panel, change the Custom width to 4 points.

  5. In the Uicontrols and axes panel, select Keep axes limits and tick spacing to prevent tick marks and limits from possibly being rescaled when you export.

  6. Click Apply to Figure. The changes appear in the figure window.

    If you don't like the way your figure looks with the new settings, restore it to its original settings by clicking the Restore Figure button.

  7. In the left pane of the Preferences dialog box, expand the Figure Copy Template topic. Select Copy Options.

  8. In the Copy Options panel, select Metafile to export the figure in EMF format.

  9. Check that Transparent background is selected. This choice makes the figure background transparent and allows the slide background to frame the axes part of the figure.

  10. Clear the Match figure screen size check box so that you can use your own figure size settings.

  11. Click OK.

  12. Select Export Setup from the figure window's File menu.

  13. Select the Size properties, and set Width to 6 and Height to 4.5. Make sure that Units are set to inches.

  14. Click Close.

  15. Select Copy Figure from the Edit menu. Your figure is now exported to the clipboard and can be pasted into a Windows application, such as PowerPoint. On Macintosh computers, MATLAB exports the figure in the best format (bit-mapped or vector) based on the figure content.

Using MATLAB Commands

Use the print function and one of two clipboard formats (-dmeta, -dbitmap) to export a figure to the clipboard. Do not specify a filename.

This example exports a figure to the clipboard in enhanced metafile (EMF) format.

print -dmeta

This example exports a figure to the clipboard in bitmap (BMP) 8-bit color format.

print -dbitmap
Was this topic helpful?