ParaMonte MATLAB 3.0.0
Parallel Monte Carlo and Machine Learning Library
See the latest version documentation.
savefig.m File Reference

Go to the source code of this file.

Functions

function savefig (in varargin)
 Export figures in a publication-quality format.
More...
 

Function Documentation

◆ savefig()

function savefig ( in  varargin)

Export figures in a publication-quality format.

This function saves a figure or single axes to one or more vector and/or bitmap file formats, and/or outputs a rasterized version to the workspace, with the following properties:

  1. Figure/axes reproduced as it appears on screen.
  2. Cropped/padded borders (optional).
  3. Embedded fonts (vector formats).
  4. Improved line and grid line styles.
  5. Anti-aliased graphics (bitmap formats).
  6. Render images at native resolution (optional for bitmap formats).
  7. Transparent background supported (pdf, eps, png, tif, gif).
  8. Semi-transparent patch objects supported (png, tif).
  9. RGB, CMYK or grayscale output (CMYK only with pdf, eps, tif).
  10. Variable image compression, including lossless (pdf, eps, jpg).
  11. Optional rounded line-caps (pdf, eps).
  12. Optionally append to file (pdf, tif, gif).
  13. Vector formats: pdf, eps, emf, svg.
  14. Bitmap formats: png, tif, jpg, bmp, gif, clipboard, export to workspace.

This function is especially suited to exporting figures for use in publications and presentations, because of the high quality and portability of media produced.

Note that the background color and figure dimensions are reproduced (the latter approximately, and ignoring cropping & magnification) in the output file.
For transparent background (and semi-transparent patch objects), use the -transparent option or set the figure 'Color' property to 'none'.
To make axes transparent set the axes 'Color' property to 'none'.
PDF, EPS, TIF, and PNG are the only formats that support a transparent background.
Only TIF and PNG formats support transparency of patch objects.

The choice of renderer (opengl/zbuffer/painters) has a large impact on the output quality.
The default value (opengl for bitmaps, painters for vector formats) generally gives good results, but if you are not satisfied then try another renderer.

Note
  1. For vector formats (EPS,PDF), only painters generates vector graphics.
  2. For bitmap formats, only opengl correctly renders transparent patches.
  3. For bitmap formats, only painters correctly scales line dash and dot lengths when magnifying or anti-aliasing.
  4. Fonts may be substitued with Courier when using painters.

When exporting to vector format (PDF & EPS) and bitmap format using the painters renderer, this function requires that ghostscript is installed on your system.
You can download this from: http://www.ghostscript.com
When exporting to EPS it additionally requires pdftops, from the Xpdf suite of functions.
You can download this from: http://xpdfreader.com

SVG output uses MATLAB's built-in SVG export if available, or otherwise the fig2svg (https://github.com/kupiqu/fig2svg) or plot2svg (https://github.com/jschwizer99/plot2svg) utilities, if available.

Note
Cropping and padding are not supported in SVG and EMF output.
Parameters
[in]varargin: Any property, value pair of the following set:
  1. filename - string containing the name (optionally including full or relative path) of the file the figure is to be saved as.
    If no path is specified, the figure is saved in the current folder.
    If no name and no output arguments are specified, the figure FileName property is used.
    If this property is empty, then the default name 'export_fig_out' is used.
    If neither file extension nor a format parameter are specified, a ".png" is added to the filename and the figure saved in PNG format.

  2. -<format> - string(s) containing the output file extension(s).
    Options are '-pdf', '-eps', 'emf', '-svg', '-png', '-tif', '-jpg', '-gif', '-bmp'.
    Multiple formats can be specified, without restriction.
    For example: savefig('-jpg', '-pdf', '-png', ...).
    Note that '-tif', '-tiff' are equivalent, and so are '-jpg','-jpeg'.

  3. -transparent - option indicating that the figure background is to be made transparent (PNG, PDF, TIF, EPS, EMF formats only). Implies -noinvert.

  4. -nocrop - option indicating that empty margins should not be cropped.

  5. -c[<val>,<val>,<val>,<val>] - option indicating crop amounts.
    It must be a 4-element vector of numeric values: [top, right, bottom, left].
    where NaN/Inf indicates auto-cropping, 0 means no cropping, any other value means cropping in pixel amounts. e.g. '-c7,15,0,NaN' Note: this option is not supported by SVG and EMF formats.

  6. -p<val> - option to pad a border of width val to exported files, where val is either a relative size with respect to cropped image size (i.e. p=0.01 adds a 1% border).
    For EPS and PDF formats, val can also be integer in units of 1/72 points (abs(val)>1).
    The input val can be positive (padding) or negative (extra cropping).
    If used, the -nocrop flag will be ignored, i.e. the image will always be cropped and then padded. Default: 0 (i.e. no padding).
    Note: this option is not supported by SVG and EMF formats.

  7. -m<val> - option val indicates the factor to magnify the figure dimensions when generating bitmap outputs (does not affect vector formats).
    Default: '-m1' (i.e. val=1). Note: val~=1 slows down savefig.

  8. -r<val> - option val indicates the resolution (in pixels per inch) to export bitmap and vector outputs, without changing dimensions of the on-screen figure. Default: '-r864' (for vector output only).
    Note: -m option overrides -r option for bitmap exports only.

  9. -native - option indicating that the output resolution (when outputting a bitmap format) should be such that the vertical resolution of the first suitable image found in the figure is at the native resolution of that image.
    To specify a particular image to use, give it the tag 'export_fig_native'.
    Notes: This overrides any value set with the -m and -r options.
    It also assumes that the image is displayed front-to-parallel with the screen.
    The output resolution is approximate and should not be relied upon.
    Anti-aliasing can have adverse effects on image quality (disable with the -a1 option).

  10. -a1, -a2, -a3, -a4 - option indicating the amount of anti-aliasing (AA) to use for bitmap outputs, when GraphicsSmoothing is not available.
    '-a1'=no AA; '-a4'=max.
    Default: 3 for HG1, 1 for HG2.

  11. -<renderer> - option to force a particular renderer (painters, opengl or [in R2014a or older] zbuffer).
    Default value: opengl for bitmap formats or figures with patches and/or transparent annotations and painters for vector formats without patches/transparencies.

  12. -<colorspace> - option indicating which colorspace color figures should be saved in: RGB (default), CMYK or gray. Usage example: '-gray'.
    Note: CMYK is only supported in PDF, EPS and TIF formats.

  13. -q<val> - option to vary bitmap image quality (PDF, EPS, JPG formats only).
    A larger val, in the range 0-100, produces higher quality and lower compression. val > 100 results in lossless compression.
    Default: '-q95' for JPG, ghostscript prepress default for PDF,EPS.
    Note: lossless compression can sometimes give a smaller file size than the default lossy compression, depending on the image type.

  14. -n<val> - option to set minimum output image size (bitmap formats only).
    The output size can be specified as a single value (for both rows and cols, e.g. -n200) or comma-separated values (e.g. -n300,400).
    Use an Inf value to keep a dimension unchanged (e.g. -n50,inf).
    Use a NaN value to keep aspect ratio unchanged (e.g. -n50,nan).

  15. -x<val> - option to set maximum output image size (bitmap formats only).
    The output size can be specified as a single value (for both rows and cols, e.g. -x200) or comma-separated values (e.g. -x300,400).
    Use an Inf value to keep a dimension unchanged (e.g. -x50,inf).
    Use a NaN value to keep aspect ratio unchanged (e.g. -x50,nan).

  16. -s<val> - option to scale output image to specific size (bitmap formats only).
    The fixed size can be specified as a single value (for rows=cols) or comma-separated values (e.g. -s300,400).
    Each value can be a scalar integer (signifying pixels) or percentage (e.g. -s125%).
    The scaling is done last, after any other cropping/rescaling due to other params.

  17. -append - option indicating that if the file already exists the figure is to be appended as a new page, instead of being overwritten (default).
    PDF, TIF & GIF output formats only (multi-image GIF = animated).

  18. -bookmark - option to indicate that a bookmark with the name of the figure is to be created in the output file (PDF format only).

  19. -clipboard - option to save output as an image on the system clipboard.

  20. -clipboard<:format> - copies to clipboard in the specified format: image (default), bitmap, emf, or pdf.
    Note that Only -clipboard (or -clipboard:image, which is the same) applies savefig parameters such as cropping, padding etc:

    1. -clipboard:image create a bitmap image using savefig processing.
    2. -clipboard:bitmap create a bitmap image as-is (no auto-cropping etc.).
    3. -clipboard:emf is vector format without auto-cropping; Windows-only.
    4. -clipboard:pdf is vector format without cropping; not universally supported.

  21. -d<gs_option> - option to indicate a ghostscript setting. For example, -dMaxBitmap=0 or -dNoOutputFonts (Ghostscript 9.15+).

  22. -depsc - option to use EPS level-3 rather than the default level-2 print device. This solves some bugs with MATLAB's default -depsc2 device such as discolored subplot lines on images (vector formats only).

  23. -metadata <metaDataInfo> - adds the specified meta-data information to the exported file (PDF format only). metaDataInfo must be either a struct or a cell array with pairs of values: {'fieldName', fieldValue, ...}.
    Common metadata fields: Title, Author, Creator, Producer, Subject, Keywords.

  24. -update - option to download and install the latest version of savefig.

  25. -version - return the current savefig version, without any figure export.

  26. -nofontswap - option to avoid font swapping. Font swapping is automatically done in vector formats (only): 11 standard MATLAB fonts are replaced by the original figure fonts. This option prevents this.

  27. -font_space <char> - option to set a spacer character for font-names that contain spaces, used by EPS/PDF. Default: ''.

  28. -linecaps - option to create rounded line-caps (vector formats only).

  29. -noinvert - option to avoid setting figure's InvertHardcopy property to 'off' during output (this solves some problems of empty outputs).

  30. -preserve_size - option to preserve the figure's PaperSize property in output file (PDF/EPS formats only; default is to not preserve it).

  31. -options <optionsStruct> - format-specific parameters as defined in MATLAB documentation of the imwrite function, contained in a struct under the format name. For example to specify the JPG Comment parameter, pass a struct such as this: options.JPG.Comment='abc'. Similarly, options.PNG.BitDepth=4. Only used by PNG,TIF,JPG,GIF output formats.
    Options can also be specified as a cell array of name-value pairs, e.g. {'BitDepth',4, 'Author','Yair'} - these options will be used by all supported output formats of the savefig command.

  32. -silent - option to avoid various warning and informational messages, such as version update checks, transparency or renderer issues, etc.

  33. -notify - option to notify the user when export is done, in both a console message and a popup dialog (allow opening the exported file/folder).

  34. -regexprep <old> <new> - replaces all occurances of <old> (a regular expression string or array of strings; case-sensitive), with the corresponding <new> string(s), in EPS/PDF files (only). See regexp function doc.
    Warning: invalid replacement can make your EPS/PDF file unreadable!

  35. -toolbar - adds an interactive export button to the figure toolbar.

  36. -menubar - adds an interactive export menu to the figure menubar.

  37. -contextmenu - adds interactive export menu to figure context-menu (right-click)

  38. handle - handle of the figure, axes or uipanels (can be an array of handles but all the objects must be in the same figure) to be exported.
    Default: gcf (handle of current figure).

  39. figName - name (title) of the figure to export (e.g. 'Figure 1' or 'My fig').
    Overridden by handle (if specified); Default: current figure.
Returns
imageData : The output image cube of type uint8 of shape [M, N, C] containing the exported figure data.
alpha : The output image matrix of shape [M, N] of alpha-matte values in the range [0, 1] for the case of transparent background.


Possible calling interfaces

imageData = pm.vis.figure.savefig(varargin)
[imageData, alpha] = pm.vis.figure.savefig(varargin)
pm.vis.figure.savefig filename
pm.vis.figure.savefig ... -<format>
pm.vis.figure.savefig ... -nocrop
pm.vis.figure.savefig ... -c[<val>,<val>,<val>,<val>]
pm.vis.figure.savefig ... -transparent
pm.vis.figure.savefig ... -native
pm.vis.figure.savefig ... -m<val>
pm.vis.figure.savefig ... -r<val>
pm.vis.figure.savefig ... -a<val>
pm.vis.figure.savefig ... -q<val>
pm.vis.figure.savefig ... -p<val>
pm.vis.figure.savefig ... -n<val> or: -n<val>,<val>
pm.vis.figure.savefig ... -x<val> or: -x<val>,<val>
pm.vis.figure.savefig ... -s<val> or: -s<val>,<val>
pm.vis.figure.savefig ... -d<gs_option>
pm.vis.figure.savefig ... -depsc
pm.vis.figure.savefig ... -metadata <metaDataInfo>
pm.vis.figure.savefig ... -<renderer>
pm.vis.figure.savefig ... -<colorspace>
pm.vis.figure.savefig ... -append
pm.vis.figure.savefig ... -bookmark
pm.vis.figure.savefig ... -clipboard<:format>
pm.vis.figure.savefig ... -update
pm.vis.figure.savefig ... -version
pm.vis.figure.savefig ... -nofontswap
pm.vis.figure.savefig ... -font_space <char>
pm.vis.figure.savefig ... -linecaps
pm.vis.figure.savefig ... -noinvert
pm.vis.figure.savefig ... -preserve_size
pm.vis.figure.savefig ... -options <optionsStruct>
pm.vis.figure.savefig ... -silent
pm.vis.figure.savefig ... -notify
pm.vis.figure.savefig ... -regexprep <pattern> <replace>
pm.vis.figure.savefig ... -toolbar
pm.vis.figure.savefig ... -menubar
pm.vis.figure.savefig ... -contextmenu
pm.vis.figure.savefig(..., handle)
pm.vis.figure.savefig(..., figName)
function version(in silent)
Return a scalar MATLAB string containing the latest available ParaMonte MATLAB version newer than the...
Note
This function is a reimplementation of the MATLAB package export_fig.


Example usage

pm.vis.figure.savefig(); % export the current figure with the default name.
pm.vis.figure.savefig("gridplot.pdf") % export figure to the specified PDF file.
pm.vis.figure.savefig("gridplot.png", "-m4 -transparent") % export a large png plot of magnitude 4 with transparency.
function name(in vendor)
Return the MPI library name as used in naming the ParaMonte MATLAB shared libraries.


Final Remarks


If you believe this algorithm or its documentation can be improved, we appreciate your contribution and help to edit this page's documentation and source file on GitHub.
For details on the naming abbreviations, see this page.
For details on the naming conventions, see this page.
This software is distributed under the MIT license with additional terms outlined below.

  1. If you use any parts or concepts from this library to any extent, please acknowledge the usage by citing the relevant publications of the ParaMonte library.
  2. If you regenerate any parts/ideas from this library in a programming environment other than those currently supported by this ParaMonte library (i.e., other than C, C++, Fortran, MATLAB, Python, R), please also ask the end users to cite this original ParaMonte library.

This software is available to the public under a highly permissive license.
Help us justify its continued development and maintenance by acknowledging its benefit to society, distributing it, and contributing to it.

Copyright (C) Oliver Woodford 2008-2014, Yair Altman 2015-

///  The idea of using ghostscript is inspired by Peder Axensten's SAVEFIG
///  (fex id: 10889) which is itself inspired by EPS2PDF (fex id: 5782).
///  The idea for using pdftops came from the MATLAB newsgroup (id: 168171).
///  The idea of editing the EPS file to change line styles comes from Jiro
///  Doke's FIXPSLINESTYLE (fex id: 17928).
///  The idea of changing dash length with line width came from comments on
///  fex id: 5743, but the implementation is mine :)
///  The idea of anti-aliasing bitmaps came from Anders Brun's MYAA (fex id: 20979).
///  The idea of appending figures in pdfs came from Matt C in comments on the
///  FEX (id: 23629)
///  Thanks to Roland Martin for pointing out the colour MATLAB
///  bug/feature with colorbar axes and transparent backgrounds.
///  Thanks also to Andrew Matthews for describing a bug to do with the figure
///  size changing in -nodisplay mode. I couldn't reproduce it, but included a
///  fix anyway.
///  Thanks to Tammy Threadgill for reporting a bug where an axes is not
///  isolated from gui objects.
///
///  23/02/12: Ensure that axes limits don't change during printing
///  14/03/12: Fix bug in fixing the axes limits (thanks to Tobias Lamour for reporting it).
///  02/05/12: Incorporate patch of Petr Nechaev (many thanks), enabling bookmarking of figures in pdf files.
///  09/05/12: Incorporate patch of Arcelia Arrieta (many thanks), to keep tick marks fixed.
///  12/12/12: Add support for isolating uipanels. Thanks to michael for suggesting it.
///  25/09/13: Add support for changing resolution in vector formats. Thanks to Jan Jaap Meijer for suggesting it.
///  07/05/14: Add support for '~' at start of path. Thanks to Sally Warner for suggesting it.
///  24/02/15: Fix MATLAB R2014b bug (issue #34): plot markers are not displayed when ZLimMode='manual'
///  25/02/15: Fix issue #4 (using HG2 on R2014a and earlier)
///  25/02/15: Fix issue #21 (bold TeX axes labels/titles in R2014b)
///  26/02/15: If temp dir is not writable, use the user-specified folder for temporary EPS/PDF files (Javier Paredes)
///  27/02/15: Modified repository URL from github.com/ojwoodford to /altmany; Indented main function; Added top-level try-catch block to display useful workarounds
///  28/02/15: Enable users to specify optional ghostscript options (issue #36)
///  06/03/15: Improved image padding & cropping thanks to Oscar Hartogensis
///  26/03/15: Fixed issue #49 (bug with transparent grayscale images); fixed out-of-memory issue
///  26/03/15: Fixed issue #42: non-normalized annotations on HG1
///  26/03/15: Fixed issue #46: Ghostscript crash if figure units <> pixels
///  27/03/15: Fixed issue #39: bad export of transparent annotations/patches
///  28/03/15: Fixed issue #50: error on some MATLAB versions with the fix for issue #42
///  29/03/15: Fixed issue #33: bugs in MATLAB's print() function with -cmyk
///  29/03/15: Improved processing of input args (accept space between param name & value, related to issue #51)
///  30/03/15: When exporting *.fig files, then saveas *.fig if figure is open, otherwise export the specified fig file
///  30/03/15: Fixed edge case bug introduced yesterday (commit #ae1755bd2e11dc4e99b95a7681f6e211b3fa9358)
///  09/04/15: Consolidated header comment sections; initialize output vars only if requested (nargout>0)
///  14/04/15: Workaround for issue #45: lines in image subplots are exported in invalid color
///  15/04/15: Fixed edge-case in parsing input parameters; fixed help section to show the -depsc option (issue #45)
///  21/04/15: Bug fix: Ghostscript croaks on % chars in output PDF file (reported by Sven on FEX page, 15-Jul-2014)
///  22/04/15: Bug fix: Pdftops croaks on relative paths (reported by Tintin Milou on FEX page, 19-Jan-2015)
///  04/05/15: Merged fix #63 (Kevin Mattheus Moerman): prevent tick-label changes during export
///  07/05/15: Partial fix for issue #65: PDF export used painters rather than opengl renderer (thanks Nguyenr)
///  08/05/15: Fixed issue #65: bad PDF append since commit #e9f3cdf 21/04/15 (thanks Robert Nguyen)
///  12/05/15: Fixed issue #67: exponent labels cropped in export, since fix #63 (04/05/15)
///  28/05/15: Fixed issue #69: set non-bold label font only if the string contains symbols (\beta etc.), followup to issue #21
///  29/05/15: Added informative error message in case user requested SVG output (issue #72)
///  09/06/15: Fixed issue #58: -transparent removed anti-aliasing when exporting to PNG
///  19/06/15: Added -update option to download and install the latest version of savefig
///  07/07/15: Added -nofontswap option to avoid font-swapping in EPS/PDF
///  16/07/15: Fixed problem with anti-aliasing on old MATLAB releases
///  11/09/15: Fixed issue #103: magnification must never become negative; also fixed reported error msg in parsing input params
///  26/09/15: Alert if trying to export transparent patches/areas to non-PNG outputs (issue #108)
///  04/10/15: Do not suggest workarounds for certain errors that have already been handled previously
///  01/11/15: Fixed issue #112: use same renderer in print2eps as savefig (thanks to Jesús Pestana Puerta)
///  10/11/15: Custom GS installation webpage for MacOS. Thanks to Andy Hueni via FEX
///  19/11/15: Fixed clipboard export in R2015b (thanks to Dan K via FEX)
///  21/02/16: Added -c option for indicating specific crop amounts (idea by Cedric Noordam on FEX)
///  08/05/16: Added message about possible error reason when groot.Units~=pixels (issue #149)
///  17/05/16: Fixed case of image YData containing more than 2 elements (issue #151)
///  08/08/16: Enabled exporting transparency to TIF, in addition to PNG/PDF (issue #168)
///  11/12/16: Added alert in case of error creating output PDF/EPS file (issue #179)
///  13/12/16: Minor fix to the commit for issue #179 from 2 days ago
///  22/03/17: Fixed issue #187: only set manual ticks when no exponent is present
///  09/04/17: Added -linecaps option (idea by Baron Finer, issue #192)
///  15/09/17: Fixed issue #205: incorrect tick-labels when Ticks number don't match the TickLabels number
///  15/09/17: Fixed issue #210: initialize alpha map to ones instead of zeros when -transparent is not used
///  18/09/17: Added -font_space option to replace font-name spaces in EPS/PDF (workaround for issue #194)
///  18/09/17: Added -noinvert option to solve some export problems with some graphic cards (workaround for issue #197)
///  08/11/17: Fixed issue #220: axes exponent is removed in HG1 when TickMode is 'manual' (internal MATLAB bug)
///  08/11/17: Fixed issue #221: alert if the requested folder does not exist
///  19/11/17: Workaround for issue #207: alert when trying to use transparent bgcolor with -opengl
///  29/11/17: Workaround for issue #206: warn if exporting PDF/EPS for a figure that contains an image
///  11/12/17: Fixed issue #230: use OpenGL renderer when exported image contains transparency (also see issue #206)
///  30/01/18: Updated SVG message to point to https://github.com/kupiqu/plot2svg and display user-selected filename if available
///  27/02/18: Fixed issue #236: axes exponent cropped from output if on right-hand axes
///  29/05/18: Fixed issue #245: process "string" inputs just like 'char' inputs
///  13/08/18: Fixed issue #249: correct black axes color to off-black to avoid extra cropping with -transparent
///  27/08/18: Added a possible file-open reason in EPS/PDF write-error message (suggested by "craq" on FEX page)
///  22/09/18: Xpdf website changed to xpdfreader.com
///  23/09/18: Fixed issue #243: only set non-bold font (workaround for issue #69) in R2015b or earlier; warn if changing font
///  23/09/18: Workaround for issue #241: don't use -r864 in EPS/PDF outputs when -native is requested (solves black lines problem)
///  18/11/18: Issue #261: Added informative alert when trying to export a uifigure (which is not currently supported)
///  13/12/18: Issue #261: Fixed last commit for cases of specifying axes/panel handle as input, rather than a figure handle
///  13/01/19: Issue #72: Added basic SVG output support
///  04/02/19: Workaround for issues #207 and #267: -transparent implies -noinvert
///  08/03/19: Issue #269: Added ability to specify format-specific options for PNG,TIF,JPG outputs; fixed help section
///  21/03/19: Fixed the workaround for issues #207 and #267 from 4/2/19 (-transparent now does *NOT* imply -noinvert; -transparent output should now be ok in all formats)
///  12/06/19: Issue #277: Enabled preservation of figure's PaperSize in output PDF/EPS file
///  06/08/19: Remove warning message about obsolete JavaFrame in R2019b
///  30/10/19: Fixed issue #261: added support for exporting uifigures and uiaxes (thanks to idea by @MarvinILA)
///  12/12/19: Added warning in case user requested anti-aliased output on an aliased HG2 figure (issue #292)
///  15/12/19: Added promo message
///  08/01/20: (3.00) Added check for newer version online (initialized to version 3.00)
///  15/01/20: (3.01) Clarified/fixed error messages; Added error IDs; easier -update; various other small fixes
///  20/01/20: (3.02) Attempted fix for issue #285 (unsupported patch transparency in some Ghostscript versions); Improved suggested fixes message upon error
///  03/03/20: (3.03) Suggest to upload problematic EPS file in case of a Ghostscript error in eps2pdf (& don't delete this file)
///  22/03/20: (3.04) Workaround for issue #15; Alert if ghostscript file not found on MATLAB path
///  10/05/20: (3.05) Fix the generated SVG file, based on Cris Luengo's SVG_FIX_VIEWBOX; Don't generate PNG when only SVG is requested
///  02/07/20: (3.06) Significantly improved performance (speed) and fidelity of bitmap images; Return alpha matrix for bitmap images; Fixed issue #302 (-update bug); Added EMF output; Added -clipboard formats (image,bitmap,emf,pdf); Added hints for exportgraphics/copygraphics usage in certain use-cases; Added description of new version features in the update message; Fixed issue #306 (yyaxis cropping); Fixed EPS/PDF auto-cropping with -transparent
///  06/07/20: (3.07) Fixed issue #307 (bug in padding of bitmap images); Fixed axes transparency in -clipboard:emf with -transparent
///  07/07/20: (3.08) Fixed issue #308 (bug in R2019a and earlier)
///  18/07/20: (3.09) Fixed issue #310 (bug with tiny image on HG1); Fixed title cropping bug
///  23/07/20: (3.10) Fixed issues #313,314 (figure position changes if units ~= pixels); Display multiple versions change-log, if relevant; Fixed issue #312 (PNG: only use alpha channel if -transparent was requested)
///  30/07/20: (3.11) Fixed issue #317 (bug when exporting figure with non-pixels units); Potential solve also of issue #303 (size change upon export)
///  14/08/20: (3.12) Fixed some exportgraphics/copygraphics compatibility messages; Added -silent option to suppress non-critical messages; Reduced promo message display rate to once a week; Added progress messages during savefig('-update')
///  07/10/20: (3.13) Added version info and change-log links to update message (issue #322); Added -version option to return the current savefig version; Avoid JavaFrame warning message; Improved exportgraphics/copygraphics infomercial message inc. support of upcoming MATLAB R2021a
///  10/12/20: (3.14) Enabled user-specified regexp replacements in generated EPS/PDF files (issue #324)
///  01/07/21: (3.15) Added informative message in case of setopacityalpha error (issue #285)
///  26/08/21: (3.16) Fixed problem of white elements appearing transparent (issue #330); clarified some error messages
///  27/09/21: (3.17) Made MATLAB's builtin export the default for SVG, rather than fig2svg/plot2svg (issue #316); updated transparency error message (issues #285, #343); reduced promo message frequency
///  03/10/21: (3.18) Fixed warning about invalid escaped character when the output folder does not exist (issue #345)
///  25/10/21: (3.19) Fixed print error when exporting a specific subplot (issue #347); avoid duplicate error messages
///  11/12/21: (3.20) Added GIF support, including animated & transparent-background; accept format options as cell-array, not just nested struct
///  20/12/21: (3.21) Speedups; fixed exporting non-current figure (hopefully fixes issue #318); fixed warning when appending to animated GIF
///  02/03/22: (3.22) Fixed small potential memory leak during screen-capture; expanded exportgraphics message for vector exports; fixed rotated tick labels on R2021a+
///  02/03/22: (3.23) Added -toolbar and -menubar options to add figure toolbar/menubar items for interactive figure export (issue #73); fixed edge-case bug with GIF export
///  14/03/22: (3.24) Added support for specifying figure name in addition to handle; added warning when trying to export TIF/JPG/BMP with transparency; use current figure as default handle even when its HandleVisibility is not 'on'
///  16/03/22: (3.25) Fixed occasional empty files due to excessive cropping (issues #318, #350, #351)
///  01/05/22: (3.26) Added -transparency option for TIFF files
///  15/05/22: (3.27) Fixed EPS bounding box (issue #356)
///  04/12/22: (3.28) Added -metadata option to add custom info to PDF files; fixed -clipboard export (transparent and gray-scale images; deployed apps; old Matlabs)
///  03/01/23: (3.29) Use silent mode by default in deployed apps; suggest installing ghostscript/pdftops if required yet missing; fixed invalid chars in export filename; reuse existing figure toolbar if available
///  03/02/23: (3.30) Added -contextmenu option to add interactive context-menu items; fixed: -menubar,-toolbar created the full default figure menubar/toolbar if not shown; enlarged toolbar icon; support adding savefig icon to custom toolbars; alert if specifying multiple or invalid handle(s)
///  20/02/23: (3.31) Fixed PDF quality issues as suggested by @scholnik (issues #285, #368); minor fixes for MacOS/Linux; use figure's FileName property (if available) as the default export filename; added -gif optional format parameter; Display the export folder (full pathname) in menu items when using -toolbar, -menubar and/or -contextmenu
///  21/02/23: (3.32) Fixed EPS export error handling in deployed apps; use MATLAB's builtin EPS export if pdftops is not installed or fails; disabled EMF export option on MacOS/Linux; fixed some EMF warning messages; don't export PNG if only -toolbar etc were specified
///  23/02/23: (3.33) Fixed PDF -append (issue #369); Added -notify option to notify user when the export is done; propagate all specified savefig options to -toolbar,-menubar,-contextmenu exports; -silent is no longer set by default in deployed apps (i.e. you need to call -silent explicitly)
///  23/03/23: (3.34) Fixed error when exporting axes handle to clipboard without filename (issue #372)
///  11/04/23: (3.35) Added -n,-x,-s options to set min, max, and fixed output image size (issue #315)
///  13/04/23: (3.36) Reduced (hopefully fixed) unintended EPS/PDF image cropping (issues #97, #318); clarified warning in case of PDF/EPS export of transparent patches (issues #94, #106, #108)
///  23/04/23: (3.37) Fixed run-time error with old MATLAB releases (issue #374); -notify console message about exported image now displays black (STDOUT) not red (STDERR)
///  15/05/23: (3.38) Fixed endless recursion when using savefig in Live Scripts (issue #375); don't warn about exportgraphics/copygraphics alternatives in deployed mode
///  30/05/23: (3.39) Fixed exported bgcolor of uifigures or figures in Live Scripts (issue #377)
///  06/07/23: (3.40) For Tiff compression, use AdobeDeflate codec (if available) instead of Deflate (issue #379)
///  29/11/23: (3.41) Fixed error when no filename is specified nor available in the exported figure (issue #381)
///  05/12/23: (3.42) Fixed unintended cropping of colorbar title in PDF export with -transparent (issues #382, #383)
///  07/12/23: (3.43) Fixed unintended modification of colorbar in bitmap export (issue #385)
///  
Author:
Fatemeh Bagheri, May 20 2024, 1:25 PM, NASA Goddard Space Flight Center (GSFC), Washington, D.C.
Amir Shahmoradi, May 16 2016, 9:03 AM, Oden Institute for Computational Engineering and Sciences (ICES), UT Austin