Code covered by the BSD License  

Highlights from
tightfig

5.0

5.0 | 1 rating Rate this file 17 Downloads (last 30 days) File Size: 2.35 KB File ID: #34055
image thumbnail

tightfig

by Richard Crozier

 

02 Dec 2011 (Updated 19 Jan 2012)

Remove excess margins from figures.

| Watch this File

File Information
Description

Alters a figure so that it has the minimum size necessary to
enclose all axes in the figure without excess space around them.

Works for figures containing multiple axes as subplots.

Note that tightfig will expand the figure to completely encompass all
axes if necessary.

Returns an error if the figure contains any 3D axes which have been zoomed.

Acknowledgements

The author wishes to acknowledge the following in the creation of this submission:
Get rid of the white margin in saveas or print outputs

Required Products MATLAB
MATLAB release MATLAB 7.6 (R2008a)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (2)
16 Jan 2012 Thomas

Great work... i was just going to implement it myself... but here it is ;) Thank you.

Just a minor issue:
Restoring the original axes units fails when there is only a single axes object in the figure:
            
set(hax(i), 'Units', origaxunits{i});

... since origaxunits is no cell array then. A simple if else does the trick.

19 Jan 2012 Richard Crozier

Thanks Thomas, I've submitted a new version with the fix.

Please login to add a comment or rating.
Updates
19 Jan 2012

Corrected bug noted by commenter Thomas, also tidied up some other parts of code and comments.

Tag Activity for this File
Tag Applied By Date/Time
figure Richard Crozier 02 Dec 2011 09:12:33
tight Richard Crozier 02 Dec 2011 09:12:34
magrgin Richard Crozier 02 Dec 2011 09:12:34
margins Richard Crozier 02 Dec 2011 09:12:34
axes Richard Crozier 02 Dec 2011 09:12:34
excess Richard Crozier 02 Dec 2011 09:12:34
white space Richard Crozier 02 Dec 2011 09:12:34
publication Richard Crozier 02 Dec 2011 09:12:34

Contact us at files@mathworks.com