File Exchange Pick of the Week

Our best user submissions

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Creating and Exporting Publication-Quality Graphics 6

Posted by Brett Shoelson,

Brett's Pick this week is export_fig, by Oliver Woodford. Frequently, when I'm bantering about MATLAB at cocktail parties, the question of how to create "publication-quality" graphics from MATLAB arises. Many of you do great work using our tools, but are stymied when it comes time to publish your results with high-end plots and figures. To address these questions, I've started maintaining a list of resources that facilitate the creation of such graphics; Oliver's "export_fig" has recently found its way onto my list.  


Oliver's contribution

Function export_fig is described on the File Exchange with this verbiage: 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 (vector formats)
  • 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 only)
  • Vector formats: pdf, eps
  • Bitmap formats: png, tif, 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. There are several things I particularly like about export_fig. (Others have liked it, too; as of this writing, the entry was downloaded 737 times in the last month alone, and has an average user rating of 4.9 out of 5, from 28 ratings!) The code is well-implemented, and appears to be pretty robust. Also, the function is nicely documented (though it might be useful to include an example or two). I also like how responsive Oliver has been in responding to queries and suggestions. The file has been updated 21 times (!) since it was originally posted in April, 2009, largely in response to user suggestions and bug reports. That's responsive, and great use of the MATLAB Central File Exchange!

Other useful resources and links

MathWorker Ben Hinkle wrote a two-part MATLAB Digest article many years ago that has stood the test of time. In part 1, he discussed the issue, and introduced his exportfig, with which one could control basic graphic properties and create EPS figures. In part 2, Ben also provided some additional functions, including the ability to preview or restore figures. Fellow Pick-of-the-Week blogger Jiro guest blogged on "Loren on the Art of MATLAB" about how to "make graphs pretty". You might also check out Oliver's fix_lines submission for "Fixing Postscript Lines," featured as a Pick of the Week back in January. Finally, these doc pages might be useful in this regard: Comments?

Get the MATLAB code

Published with MATLAB® 7.10


Comments are closed.

6 CommentsOldest to Newest

Oliver Woodford replied on : 1 of 6
Thanks for the honour, Brett. I think the point about examples is very valid, and an excellent idea; it might cut down the email queries too! What I'll probably do is create a web page with some examples, and link to it from the FEX and also export_fig's help text. Thanks for the input. Oliver
Marko Budisic replied on : 2 of 6
I really like using LaPrint for generating publication-grade figures. It converts text to latex code that fits well with the rest of the paper (if it's in latex, of course).
Matt Williams replied on : 3 of 6
It seems that Matlab's deficiency in the area of creating publication-quality figures is well-known and has been for some time. The code fix_lines.m, for instance, has been at Matlab Central for more than a year. I'm excited that there are so many user-generated codes out there for helping Matlab figures reach publication-quality (and that you're telling us about them!), but this begs the question: is there anything being done at Mathworks to address the problems directly in Matlab? Is backwards compatibility the hold-up?
Danyer replied on : 4 of 6
Dear Mr. Woodford, I would like to download your export_fig from your website. However, the site of has been blocked by some reason. Could you please give me another link to me or send me the example of usage for export_fig? Thanks so much in advance.
Lars Barring replied on : 5 of 6
Oliver's export_fig do indeed help out (thanks Oliver!) with some of the hurdles I have been ranting about elsewhere, e.g. and here to take two recent examples. But the commands legend, colorbar, boxplot all three work nicely when plotting on screen or not trying to do any customization. Once that stage is over and one want to take full control of the details and components of these objects Matlab becomes considerable more difficult. So I can only second Matt William's comment and plea for some insight into the background to this state of affairs, as well as suggest that you (or one of the other bloggers) give a rundown on how to take full control of the details of these three commands (and similar ones that others can come up with). Lars
Scott Hirsch replied on : 6 of 6
@Matt Williams: We realize that there have been many long-standing challenges associated with generating publication-quality graphics from MATLAB. This is an area where we are very interested in improving, and I can say that we are working quite hard on it right now.