Documentation

This is machine translation

Translated by
Mouse over text to see original. Click the button below to return to the English verison of the page.

Save Figure to Open in Another Application

Choose File Format

Before saving the figure, consider the file format you want to use. You can save the figure as either a bitmap image or a vector graphics file.

• Bitmap images contain a pixel-based representation of the figure. This type of format is widely used by web browsers and other applications that display graphics. However, bitmap images do not scale well. You cannot modify individual graphics objects, such as lines and text, in other graphics applications. Supported bitmap image formats include PNG and JPEG.

• Vector graphics files store commands that redraw the figure. This type of format scales well, but can result in a large file. Also, vector graphics files might not produce the correct 3-D arrangement of objects in certain cases. Some applications support extensive editing of vector graphics formats, but some applications support only resizing the graphic. In general, try to make all the necessary changes while your figure is still in MATLAB®. Supported vector graphics formats include PDF, EPS, and SVG.

For a full list of supported file formats, see File Format Options.

Save Figure for Document or Presentation

To save a figure, use either the saveas or print function. For example, save a bar chart as a PNG file. Use gcf to save the current figure.

bar([1 10 7 8 2 2 9 3 6]) saveas(gcf,'BarChartFile.png')

If you want additional control over the saved output, such as setting the resolution or controlling the renderer, use the print function to save the figure instead.

 Note:   Details of saved and printed figures can differ from the figure on the display. To get output that is more consistent with the display, see Save Figure Preserving Background Color and Save Figure at Specific Size and Resolution.

Save Figure for Editing in Another Application

If you want to edit a figure in another application, save it as a vector graphics file, such as PDF or EPS. Use either the saveas or print function to save the figure.

For example, save a bar chart as an EPS file with color using the 'epsc' file format.

bar([1 10 7 8 2 2 9 3 6]) saveas(gcf,'BarChartFile','epsc')

saveas saves the bar chart as BarChartFile.eps. For a black and white EPS file, use the 'eps' format instead. For a full list of supported file formats, see File Format Options.

Customize Figure Before Saving

Customizing your figure in MATLAB before you save it can eliminate the need to use another application for editing.

To customize the figure programmatically, set properties of the graphics objects. Typically, graphics functions return output arguments that you can use to access and modify graphics objects. For example, assign the chart line objects returned from the plot function to a variable and set their LineWidth property.

p = plot(rand(5)); set(p,'LineWidth',3)

If you do not return the graphics objects as output arguments, you can use findobj to find objects with certain properties. For example, find all objects in the current figure with a Type property set to 'line'. Then, set their LineWidth property.

plot(rand(5)) p = findobj(gcf,'Type','line') set(p,'LineWidth',3); 

For a list of all graphics objects and their properties, see Graphics Object Properties.

To customize the figure interactively, use either the Plot Tools or the Export Setup dialog. For more information on the Plot Tools, see Customize Graph Using Plot Tools. For more information on the Export Setup dialog, see Customize Figure Interactively Before Saving.

Include Figure in Microsoft Application or LaTeX Document

To import a figure into a Microsoft® application, such as Word or PowerPoint®, click Insert > Picture > From File in the application. Then, navigate to your saved file.

To add a figure to a LaTeX document, first save the figure using an EPS format. For example, saveas(gcf,'BarChart','epsc'). Then, use the \includegraphics element in the LaTeX document to include the file. For example:

\documentclass{article} \usepackage{graphicx} \begin{document} \begin{figure}[h] \centerline{\includegraphics[height=10cm]{BarChart.eps}} \caption{Bar Chart from MATLAB} \end{figure} \end{document} 

File Format Options

This table lists the supported bitmap image formats.

OptionBitmap Image FormatCorresponding File Extension
'jpeg'JPEG 24-bit.jpg
'png'PNG 24-bit.png
'tiff'TIFF 24-bit (compressed).tif
'tiffn'TIFF 24-bit (not compressed).tif
'meta'Enhanced metafile (Windows only).emf
'bmpmono'BMP Monochrome .bmp
'bmp'BMP 24-bit .bmp
'bmp16m'BMP 24-bit .bmp
'bmp256'BMP 8-bit (256 color, uses a fixed colormap) .bmp
'hdf'HDF 24-bit.hdf
'pbm'PBM (plain format) 1-bit.pbm
'pbmraw'PBM (raw format) 1-bit.pbm
'pcxmono'PCX 1-bit.pcx
'pcx24b'PCX 24-bit color (three 8-bit planes).pcx
'pcx256'PCX 8-bit newer color (256 color).pcx
'pcx16'PCX older color (EGA/VGA 16-color).pcx
'pgm'PGM (plain format).pgm
'pgmraw'PGM (raw format).pgm
'ppm'PPM (plain format).ppm
'ppmraw'PPM (raw format).ppm

This table lists the supported vector graphics formats.

OptionVector Graphics FormatCorresponding File Extension
'pdf'Full page Portable Document Format (PDF) color.pdf
'eps'Encapsulated PostScript® (EPS) Level 3 black and white.eps
'epsc'Encapsulated PostScript (EPS) Level 3 color.eps
'eps2'Encapsulated PostScript (EPS) Level 2 black and white.eps
'epsc2'Encapsulated PostScript (EPS) Level 2 color.eps
'meta'Enhanced Metafile (Windows® only).emf
'svg'SVG (Scalable Vector Graphics).svg
'ps'Full-page PostScript (PS) Level 3 black and white.ps
'psc'Full-page PostScript (PS) Level 3 color.ps
'ps2'Full-page PostScript (PS) Level 2 black and white.ps
'psc2'Full-page PostScript (PS) Level 2 color.ps