|On this page…|
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.
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'.
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).
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]);
This example sets the size of a figure to 5.5-by-3 inches and centers it on the paper.
set(gcf, 'PaperUnits', 'inches')
papersize = get(gcf, 'PaperSize') papersize = 8.5000 11.0000
width = 5.5; % Initialize a variable for width. height = 3; % Initialize a variable for height.
left = (papersize(1)- width)/2 left = 1.5000
bottom = (papersize(2)- height)/2 bottom = 4
myfiguresize = [left, bottom, width, height]; set(gcf, 'PaperPosition', myfiguresize); print
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.
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
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
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.
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.
x = -pi:0.01:pi; h = plot(x, sin(x)); title('Sine Plot');
Note: In Macintosh®, the Figure Copy Template Preferences panel is not displayed. For more information on how to export figures in Macintosh, see Exporting to the Windows or Macintosh Clipboard.
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.
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.
This example exports a figure to the clipboard in bitmap (BMP) 8-bit color format.