Main Content

hgexport

(To be removed) Export contents of figure

    hgexport will be removed in a future release. Use exportgraphics instead. (since R2020a) For more information, see Version History.

    Description

    example

    hgexport(fig,filename) exports the contents of the figure fig to an EPS file with the specified file name.

    hgexport(fig,"-clipboard") copies the contents of the figure to the clipboard. This syntax is supported on Windows® systems only.

    The content is copied either as vector graphics or as an image, depending on the renderer. If the renderer is Painters, then the content is copied as a Windows metafile. If the renderer is OpenGL®, then the content is copied as an image. Use the rendererinfo function to determine the renderer. Changing the renderer will not be possible in a future release.

    Examples

    collapse all

    Create a plot and get the current figure by calling the gcf function.

    plot([0 0.3 0.1 0.6 0.4 1])
    fig = gcf;
    

    Line plot

    Save the contents of the figure to the file myplot.eps

    hgexport(fig,"myplot.eps")

    Input Arguments

    collapse all

    Figure to export, specified as a figure object.

    File name, specified as a string scalar or a character vector.

    Example: hgexport(gcf,"myfile.eps") specifies a string scalar for the file name.

    Example: hgexport(gcf,'myfile.eps') specifies a character vector for the file name.

    Version History

    Introduced before R2006a

    collapse all

    R2024a: To be removed

    hgexport will be removed in a future release. To save the contents of a plot as an image or vector graphics file, use the exportgraphics function. (since R2020a)

    exportgraphics has a variety of options for controlling the output. For example, you can capture plots with tight cropping around the axes, control image resolution, embed fonts in PDFs, or create multipage PDFs and animated GIFs.

    To save the contents of an app to an image file, use the exportapp function. (since R2020b)