Description | Use exportgraphics when you want to save a plot and
include it in documents, emails, or
presentations. | Use print when you
want to save a plot within a full-sized page. | Use getframe with
imwrite when
you have requirements that the other exporting functions cannot
accommodate, such as exporting to a BMP file. | Use exportapp when you want to save a user interface
(UI) you created in MATLAB and include it in documents, emails, or
presentations. |
Example | Export a plot in the current figure to a PNG file.
| Export a plot in the current figure as a full-page PDF
file.
| Capture a plot with getframe and save
it as a BMP file.
| Export an app window containing a button as a PNG
file.
|
Type of Content
Captured |
Plots and charts in a figure created with the
figure function Any type of axes Legends, colorbars, annotations Panels, tabs, tiled chart layouts
|
Plots and charts in a figure created with the
figure function Any type of axes Legends, colorbars, annotations Panels, tabs, tiled chart layouts
|
Any type of figure, including figures created with
the uifigure function Any content within the figure, including UI
components
|
Note:
exportapp does not capture the contents of
figures created with the figure
function. |
UI Component
Support | No exportgraphics does not
capture most UI components, such as buttons or sliders. However,
if you pass a UI container (such as a panel or tab) to
exportgraphics , the function captures
the plots in that container.
| print
captures UI components in figures created with the figure
function. This functionality will be removed in a future
release.
print does not capture
the contents of apps created with App Designer or figures
created with the uifigure
function.
| Yes | Yes |
File Formats
Supported | exportgraphics supports these
formats:
Images: PNG, JPG, TIFF, and GIF Vector graphics: EPS, EMF, and PDF Animated images: GIF
| print supports these formats:
Images: PNG, JPG, and TIFF Vector graphics: EPS, EMF, PDF, and SVG
| imwrite supports these formats:
Images: HDF4, PNG, JPG, TIFF, BMP, PBM, PGM, PPM,
PCX, RAS, and GIF Animated images: GIF
| exportapp supports these
formats:
Images: PNG, JPG, and TIFF Vector graphics: PDF (Only UI components are
stored as vector graphics; all other content, such
as plots, are stored as images within the
PDF.)
|
Multipage PDF
Support | Yes | No | No | No |
Cropping
Control | No exportgraphics crops
the output tightly around the axes and any associated titles,
labels, colorbars, and legends.
| No print captures all the
contents of the figure, including the white space that surrounds
plots and other items in the figure.
| The rect input argument of the
getframe function enables you to select
a section of the figure to capture. | No exportapp captures all
the contents of the app window, including the white space that
surrounds UI components and plots.
|
Full-Page Format
Support | No | Full-page controls are available for PDF or hard copy
output by setting certain properties of the figure. See the
Tips section of the
print page for more
information. | No | No |
Embedded Font Support | exportgraphics automatically embeds
fonts in PDFs when the fonts are embeddable.
| No | No | exportapp automatically embeds fonts
in PDFs when the fonts are embeddable.
|
Width and Height
Control | No However, you can control the dimensions of
the output by plotting into a tiled chart layout. See Specify Size for an
example. |
Page formats (PDF) — The PaperSize property of the figure
controls the page size. The PaperPosition property of the figure
controls the placement on the page. Non-page formats (Images, EPS, EMF, SVG) — The
PaperPosition property of the figure
controls the dimensions of the image. The
resolution input argument of
the print function controls the
number of pixels within those dimensions.
| No getframe captures the
content to match the size on your display. However,
imwrite has options for controlling how
other applications display the pixels in TIFF and PNG files.
Setting these options can affect the size of an image when it is
rendered in another application.
| No |
Resolution
Control | exportgraphics has a
Resolution name-value argument for
controlling the resolution of image files.
| print has a
resolution input argument for controlling
the resolution of image files.
| No | No exportapp captures
content at screen resolution.
|
Background Color and Transparency
Control | exportgraphics has a
BackgroundColor name-value argument for
controlling the background color and transparency:
| No However, before using
print , you can set the background color
and transparency by setting figure and axes properties:
Colored background — Set the Color property of the figure and the
Color property of the axes to the
intended color values. Then set the figure's
InvertHardcopy property to
"off" . Transparent background (vector graphics file
formats only) — Set the Color
properties of the figure and axes to
"none" . Then set the figure's
InvertHardcopy property to
"off" .
| getframe captures the background color
of the figure and axes as they appear on screen.
For
PNG output, imwrite has an
Alpha name-value argument for
controlling the transparency of pixels by location and a
Transparency name-value argument for
controlling the transparency by pixel values. | No exportapp captures the
background color as it appears in the app window.
|
Preserved Axes Limits and Ticks
Values | Yes | No To ensure that the axes limits and tick
values match your display, set all of these axes properties to
"manual" after plotting.
XTickMode ,
YTickMode , and
ZTickMode (for 3-D)
XTickLabelMode ,
YTickLabelMode , and
ZTickLabelMode (for
3-D)
XLimMode ,
YLimMode , and
ZLimMode (for 3-D)
For more information, see Axes Properties. | Yes | Yes |
Related
Functionality |
|
|
|
|