| File Information |
| Description |
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:
- Figure/axes reproduced as it appears on screen
- Cropped borders (optional)
- Embedded fonts (pdf only)
- Improved line and grid line styles
- Anti-aliased graphics (bitmap formats)
- Render images at native resolution (optional for bitmap formats)
- Transparent background supported (pdf, eps, png)
- Semi-transparent patch objects supported (png only)
- RGB, CMYK or grayscale output (CMYK only with pdf, eps, tiff)
- Variable image compression, including lossless (pdf, eps, jpg)
- Optionally append to file (pdf, tiff)
- Vector formats: pdf, eps
- Bitmap formats: png, tiff, jpg, bmp, 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, and set the axes 'Color' property to 'none' where desired. Pdf, eps and png are the only file formats to support a transparent background, whilst the png format alone supports transparency of patch objects.
When exporting to vector format (pdf & eps), and to bitmap 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://www.foolabs.com/xpdf
Usage examples can be found at:
http://sites.google.com/site/oliverwoodford/software/export_fig
When reporting bugs, please use the 'Contact Author' link on my Author page, rather than pasting the error into the comments - I will respond more quickly, especially if I can email you back. |
| Acknowledgements |
Savefig, Fix Dashed And Dotted Lines In Eps Export, Fixpslinestyle, Myaa My Anti Alias For Matlab, and Fix Lines
inspired this file.
This file inspired
Google Earth Overlay, Convert Plot4 Publication, Append Pdfs, Causal State Modeller Toolbox, Machine Learning Balancing A Stack Of Balls, Fast And Efficient Spectral Clustering, Co Blade: Software For Analysis And Design Of Composite Blades, Matlab Icon For Linux (With Transparency), Multiple Colormaps, Export Figure To 3 D Interactive Pdf, Color Checker Chart, and Eps Utility Toolbox.
|
| MATLAB release |
MATLAB 7.13 (R2011b)
|
| Other requirements |
Ghostscript, Xpdf |
| Updates |
| 15 Apr 2009 |
Added ability to export rasterized figure straight to the workspace. |
| 19 Apr 2009 |
Added ability to append to pdf files, as suggested by Matt C. Corrected some help text. |
| 21 Apr 2009 |
Incorporated Christian Dorion's patch for updating ghostscript (and also pdftops) path. Fixed bug that didn't correctly detect if pdftops path was valid (due to a MATLAB/Windows bug). |
| 24 Apr 2009 |
Added ability to compute transparency of patch objects when outputting to png and exporting to workspace. |
| 28 Jun 2009 |
Fixed bug to allow exporting of axes that are children of uipanels. Thanks to Stefan for pointing out the bug. |
| 21 Jul 2009 |
Export colorbars associated with subplots when in a uipanel. Thanks to Johannes Korsawe for pointing out the bug. |
| 29 Jul 2009 |
Added options to disable cropping and set level of anti-aliasing. Added a fix to get round a rendering bug in print (thanks to Johannes Korsawe for pointing it out). |
| 31 Jul 2009 |
Added option to use zbuffer renderer for bitmaps. This avoids some errors caused by bugs in the opengl renderer.
Fixed bug when exporting greyscale figures with an alphamatte (thanks to Annette for pointing it out). |
| 09 Oct 2009 |
Added ability to export at any resolution (bitmap outputs only) and also in CMYK colorspace (tiff, pdf, eps only). |
| 12 Nov 2009 |
Appending to end of pdf files is now off by default, and enabled by the -append option. Suggested by Clark Richards. |
| 12 Nov 2009 |
Fixed bug that meant -tif lead to jpeg being output instead. |
| 24 Nov 2009 |
Bug fix (thanks, Andreas Offenhaeuser). Added grayscale option (suggestion thanks to Bob Sica). Added correct resolution for tiff & png (sugestion thanks to Yvonne Haesevoets). |
| 25 Nov 2009 |
No change to the file, just a correction - I thank Paul Soderlind for suggesting the grayscale output option, not Bob Sica (apologies to you both). |
| 25 Nov 2009 |
Improved rendering of dashed and dotted lines for bitmap outputs using the -painters algorithm. This overcomes the "shrinking dash" problem mentioned by Yvonne Haesevoets (thanks!). |
| 02 Mar 2010 |
Added -native option for exporting to bitmap at native resolution of an image. Fixed uigetdir title problem on MAC OS X (thanks to Jonas for the bug report). |
| 03 Mar 2010 |
Improved accuracy of native resolution feature in some circumstances. |
| 05 Mar 2010 |
Added ability to vary quality/compression level for jpg, pdf & eps output. Thank you to Fabio Viola for pointing out compression artifacts using the default settings. |
| 08 Apr 2010 |
Fix to colorbar axes color bug with transparent bitmap export (thanks to Roland Martin for reporting it). Look for ghostcript in default location on 64 bit Windows (thanks to suggestion by Nathan Childress). |
| 13 Apr 2010 |
Fix for R2006b (possibly even R2007a) and earlier: move embedded fonts after bounding box information. Thanks to Sylvain Fa for reporting the problem. |
| 20 Apr 2010 |
Fix to bug which caused an error when exporting to transparent bitmap with no colorbar present (introduced 8th April 2010). Thanks to Gracee for reporting it. |
| 25 May 2010 |
Fixed bug which caused bitmaps to be poorly rendered when using the painters renderer on figures with many patches in. Also added fix to bug reported by Andrew Matthews (thanks!) affecting export in -nodisplay mode. |
| 01 Jun 2010 |
Added ability to append to tiff. Added link to usage examples web page (thanks to Brett Shoelson for the suggestion). |
| 23 Jun 2010 |
Isolate axes better in presence of gui objects (thanks to Tammy Threadgill for reporting the issue). Maintain resolution of very small images in vector formats when using lossless compression (thanks to Scott for reporting the issue). |
| 06 Oct 2010 |
Faster bitmap export using hardcopy. Better error checking for when exporting to non-existent directories (thanks to Aldebaro Klautau for reporting this). |
| 02 Feb 2011 |
Enable exporting of multiple axes (when a subset of all axes). Don't save user specific paths in .m files that may be version controlled (thanks to Jonas Dorn for the suggestion). Minor bug fixes. |
| 02 Feb 2011 |
Save user specific paths in a single, hidden directory. Put isolate_axes code in a separate function. |
| 27 Apr 2011 |
Find 64-bit Ghostscript on Windows (thanks to Paul Durack and Shaun Kline for both reporting this issue). Fix bug in isolate_axes (thanks to Rosella Blatt for reproting this). |
| 28 Apr 2011 |
Bug fix to ghostscript.m mostly affecting Linux (thanks to Paul Durack for reporting it). |
| 15 Sep 2011 |
Fix bitmap cropping with painters renderer. Make bitmap outputs exactly the right size. Suppress warnings by setting EraseModes to normal when using opengl or zbuffer renderers (thanks to Pawel Kocieniewski for reporting the issue). |
| 21 Sep 2011 |
Fix to bug in print2array causing an error when exporting using painters with a white background. Thanks to Tobiar Lamour for reporting it. |
| 14 Nov 2011 |
Various bug fixes - thanks to Phil Trinh, Mathieu Morlighem and Meelis Lootus for reporting the issues. Also added new -transparent option, and set default anti-aliasing down to -a3. |
| 08 Dec 2011 |
Allow use of arbitrary fonts with the painters renderer, e.g. in eps and pdf files. |
| 09 Dec 2011 |
More reliable export of non-standard fonts using painters renderer. |
| 14 Dec 2011 |
Fix bug affecting export using -painters with spaces in font names. Thanks to David Szwer for reporting the issue. |
| 26 Jan 2012 |
Improve font swapping behaviour. Thanks to Anna Rafferty and Adam Jackson for reporting issues. |
| 27 Jan 2012 |
Fix bug when exporting tall figures to bitmap using the painters renderer. Thanks to Ken Campbell for reporting it. |
| 23 Feb 2012 |
Ensure axes limits are the same on screen and printed. |
| 14 Mar 2012 |
A bug fix to the previous change, ensuring that axes limits are correctly set. Thanks to Tobias Lamour for reporting the issue. |
| 16 Mar 2012 |
Fixed a bug to do with copyfig not being available to export_fig. Thanks to Bob Fratantonio for pointing it out. |
| 10 Apr 2012 |
Make font swapping case insensitive. Fix bug affecting export to bitmap using painters in r2012a (thanks to Andy Matthews for reporting it). |
| 09 May 2012 |
Add ability to add bookmarks based on figure names into PDFs - thanks to Petr Nechaev for this. Keep tick marks fixed - thanks to Arcelia Arrieta for this. |
| 20 Sep 2012 |
Fix to bug introduced by R2012b |
| 05 Nov 2012 |
Bug fix to font swapping in vector formats, fixed paper orientation bug and removed conflict with the path function. Many thanks to Malcolm Hudson, Michael Watts and Michel Slivitzky for reporting those issues respectively. |
| 12 Dec 2012 |
Allow export of uipanel objects, and improve finding Ghostscript on Windows. Thanks to michael and Ratish Punnoose for highlighting these issues. |
| 22 Mar 2013 |
Access user strings in text, not binary mode, to avoid errors. Now swap fonts in axes labels when exporting in vector format. Thanks to Christian and Rasmus Ischebeck for pointing out these respective errors. |