Main Content

hgsave

Save graphics object hierarchy to file

Syntax

hgsave(filename)
hgsave(h,filename)
hgsave(...,'-v6')
hgsave(...,'-v7.3')

Description

Note

hgsave will be removed in a future release. Use savefig instead.

hgsave(filename) saves the current figure to a file named filename. Specify filename as a character vector or string.

hgsave(h,filename) saves the objects identified by the array of handles h to a file named filename. If you do not specify an extension for filename, then the extension .fig is appended. If h is a vector, none of the handles in h may be ancestors or descendents of any other handles in h.

hgsave(...,'-v6') saves the FIG-file in a format that can be loaded by versions prior to MATLAB® 7.

hgsave(...,'-v7.3') saves the FIG-file in a format that can be loaded only by MATLAB versions 7.3 and above. This format, based on HDF5 files, is intended for saving FIG-files larger than 2 GB.

Backward Compatibility

When creating a figure you want to save and use in a MATLAB version prior to MATLAB 7, use the 'v6' option with the plotting function and the '-v6' option for hgsave. Check the reference page for the plotting function you are using for more information.

Alternatives

Use the File > Export Setup dialog. Use Edit > Copy Figure to copy the figure’s content to the system clipboard. For details, see Customize Figure Before Saving and Copy Figure to Clipboard from Edit Menu.

Version History

Introduced before R2006a

collapse all

R2024b: To be removed

hgsave runs without warning, but the Code Analyzer indicates that it will be removed in a future release. Use savefig to save a FIG-files instead. savefig supports the same arguments and syntaxes that the hgsave function supports, and it saves FIG-files that are compatible with R2014b and later releases.

When hgsave is removed, you will no longer be able to save FIG-files compatible with R2014a and earlier releases.

See Also

| | |