4.19231

4.2 | 28 ratings Rate this file 158 downloads (last 30 days) File Size: 10.4 KB File ID: #727

Exportfig

by Ben Hinkle

 

13 Sep 2001 (Updated 21 Oct 2002)

No BSD License  

Functions for exporting figures.

Download Now | Watch this File

File Information
Description

A collection of 4 functions to make it easier to export figures for publication. See also http://www.mathworks.com/company/digest/december00/export.shtml

Acknowledgements
This submission has inspired the following:
BaFigExPro (v. 2.4)
MATLAB release MATLAB 6.0 (R12)
Zip File Content  
Other Files exportfig.m,
applytofig.m,
previewfig.m,
restorefig.m
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (32)
14 Sep 2001 Denis Gilbert

I have used the exportfig utility several times over the last year and highly recommend it to anyone using matlab graphics in their presentations or publications.

05 Oct 2001 Jeff Hebert

Good integration with MATLAB - ability to set default options is nice. Still screws up axis labels occaisionally but overall a must have.

21 Jan 2003 Vio B.

Very helpful for exporting "publication quality" eps figs quickly.
It still needs to be fixed to handle "single column" figures (width <=3.25in) correctly.

02 Jul 2003 Jason R.

An excellent tool -- I've found it very helpful putting together my PhD thesis.

19 Feb 2004 Stephan Zeipel

Doesn't work if Axis has no ticks

31 Mar 2004 Fred V.

solves a common bug in matlab: translation/rotation of added elements (legend, lines, arrows, text) when converting from *.fig to another picture format.

24 May 2004 john kerry  
21 Aug 2004 Mark Histed

Bug: if any tick labels are cellstrs (as opposed the char arrays), EXPORTFIG fails.

23 Aug 2004 Shi Jin

Bug: Cannot get the specified width or height correctly if the plot is maximized by the user.
I wonder if there is a version number to this package so that I can make sure I am using the latest one. Or is this package ever bug-fixed at all? Thanks.

21 Sep 2004 Magnus Nilsson

The idea is great, but on my first try it could not handle hist plots. Is there some similar function out there that works better? It would help a lot.

25 Oct 2004 jiansheng chen  
01 Jun 2005 Randall Schuh

I have used exportfig for a while, but it is slow, the code is pretty complicated and it is stripping the units off of my axes (e.g. x10^-3 is removed from the axis). It seems that these files are not being updated and I'm not sure I want to try to figure out enough of what it is doing to fix it.

18 Jul 2005 Gerard Ridgway

I think this is a really useful tool, which deserves to be included in future MATLAB releases. If Ben Hinkle doesn't have time to maintain it any more, surely someone could volunteer (just not me...)

Randall Schuh -- can you reproduce your bug? I find things like:

lab = ['\omega' sprintf('\n') '(10^{3} Hz)'];
xlabel(lab)

work fine for me.

I agree with Magnus Nilsson's bug report, but know of no better tool. You could try LaPrint

http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=4638&objectType=file

But this is takes quite a different approach, is much more complex, only usable with LaTeX, and doesn't seem to offer the very useful exportfig option of changing line styles for mono export.

18 Jul 2005 Gerard Ridgway

Ah, sorry Randall, I see what you mean.

plot(1e9)
applytofig(gcf)

strips the multiplier from the axis numbering itself, and not the axis label as I had thought.

22 Sep 2005 Madhusudhanan Balasubramanian

Use exportfig(...., 'lockAxes', 0) to freeze the axes (and prevent stripping of the exponent of the y-axis)

12 Jan 2006 Andreas Groth

I've tried the command
previewfig(gcf,'bounds','tight');
with the first example in "Exporting Figures for Publication: Part 2" and nothing happens. Only the colored lines are converted to black ones, but the bounds are the same. If I export it to eps, the labels are not correctly shown and are still clipped.
I've Matlab R13, perhaps it works only with R12?

15 Mar 2006 Anonymous User

In version 2002-10-18, line 451:

set(H,'Color','w');

isn't necessary at all. If another figure color is used, this command will undo the figure color set before. Besides, the figure property 'InvertHardcopy' is meant to handle figure color and turn it into white if necessary.

03 Apr 2006 Rentian Xiong

Worked great for me. Saved lots of time to incorporate Matlab figures with Latex. Thanks!

16 Oct 2006 Roger Svensson  
09 Jan 2007 chau nguyen

exportfig.m

01 Feb 2007 Chris Churchill

Pretty good for actually getting useful plots out of Matlab. Formatting tends to be a little bit messy, if you need to post-process in Illustrator or Inkscape.

07 Feb 2007 Chris Churchill

Another annoying problem I have found with this script which is probably related to Matlab in general: when creating greek letters or symbols in a text box on a figure using tex encoding, Matlab always defaults to display these characters in "Symbol" font, even if you explicitly set it as "Helvetica".
If you would like your figures to look correct in Adobe Illustrator, it is necessary to find a workaround for this, since it does not always display the font correctly.
Even if Greek characters are part of a font, you can not use them directly.

23 Aug 2007 Prasad Gabbur

I wanted flexibility regarding font size for a plot's legend, which does not seem to be handled well by Matlab. exportfig was helpful to me in dealing with this problem by playing with the 'FomtMode' and 'Fontsize' properties. Thanks to the authors!

05 Jan 2008 Christopher Barrington-Leigh

Very nice tool. But what else has come along in the intervening years? Matlab should provide something more like this, without bugs.
 My biggest bug with it so far is that when my hlabel includes tex formatting, the bounding box ignores (?) it and cuts it off. So I'd have to edit each figure by hand (illustrator? scribus?) to enlarge the bounding box.
Is someone maintaining this?
Well, I've nothing better for now, so am using this for my dissertation.

11 Jan 2008 Chris Barrington-Leigh

This would be much more useful if it worked in nodisplay mode (matlab -nodisplay -nojvm) for batch processing, which is vastly faster than showing everything on screen.

Exportfig fails as follows under nodisplay mode:

??? Error using ==> exportfig at 744
Error using ==> graphics/private/setset at 307
Error using ==> graphics/private/setset at 277
Error using ==> set
Width and height must be > 0.

07 Mar 2008 sharee_adil sharee  
19 Mar 2008 sarah goldberg

overall very helpful - solved a problem i was having with text labels on top of mesh plots. BUT - uses negative values for bounding box when exporting to EPS format, which is not ok for dvi->pdf (assuming you're working with latex).

27 Jun 2008 Doug Saucedo

I've been using exportfig for several years and until recently had not had issues with it. Overall this is a great function set.

I'm hoping someone will have some feedback regarding how to get exportfig to not "corrupt" subplot figures or contour plots with a colorbar. Exportfig attaches extra white space in both cases and deforms the plot in the subplot case. Thanks

14 Jul 2008 Doug Saucedo

I found a work around for my previously posted issue. I'm using the applytofig function to adjust the figures attributes then using print(fig,...) to write the image file. This is an excellent package for use with TeX/LaTeX/PDFLaTeX,etc.

19 Dec 2008 Vincent Huang

Doug, could you elaborate on this work-around a bit? Sample code involving applytofig is highly appreciated.

22 Jan 2009 Eric

Why is all this functionality not yet added to matlab's hgexport.m file? The tight bounding box calculation which includes ALL text labels vs. just the axes is clearly an improvement. I am using 7.7.0.471 (R2008b)

27 Jan 2009 Jonas  
Please login to add a comment or rating.
Updates
15 Oct 2002

some bug fixes

Tag Activity for this File
Tag Applied By Date/Time
graphics import Ben Hinkle 22 Oct 2008 06:37:35
graphics export Ben Hinkle 22 Oct 2008 06:37:35
export Ben Hinkle 22 Oct 2008 06:37:35
postscript Ben Hinkle 22 Oct 2008 06:37:35
figures Ben Hinkle 22 Oct 2008 06:37:35
publication Ben Hinkle 22 Oct 2008 06:37:35
graphics Ben Hinkle 22 Oct 2008 06:37:35
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com