4.90909

4.9 | 13 ratings Rate this file 92 Downloads (last 30 days) File Size: 3.08 KB File ID: #30736
image thumbnail

fig- the exact figure size and no white space

by

 

13 Mar 2011 (Updated )

Create publication-quality figures; easily define the figure's size, font of all labels, titles...

| Watch this File

File Information
Description

This function is especially useful for creating high-quality figures for publication. Many scientific journals require figures with specific sizes and fonts.

One annoyance of the Matlab's default figure is the complications in defining the figure's size for publication. The other thing is the extra white-space (blank margin) around the plots.

With FIG you can easily choose the desired figure size without any unnecessary white-space. Moreover you can unify the font used for all the labels, titles, legends, colorbars, etc. FIG also accepts all the arguments of the Matlab figure(...).

Example1:
               fig

Example2:
               h=fig('units','inches','width',7,'height',2,'font','Helvetica','fontsize',16)

When reporting bugs, please drop me an email, rather than reporting in the comments (I will respond more quickly, especially if I can email you back).

MATLAB release MATLAB 7.10 (R2010a)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (21)
19 Aug 2014 arnold

there seems to be a problem with distFig, which I've used all the time. http://www.mathworks.com/matlabcentral/fileexchange/37176-distribute-figures

The figures created with 'fig' just vanish from the screen instead of being distributed. Hm...

25 Mar 2014 Phillip

Does not work for imshow?
It still produces boarders for me...
:(

20 Nov 2013 giovdain  
10 May 2013 arnold

Hi Reza,

your function works as advertised yet I don't understand why setting a width and height in centimeters/inch is of any value if no resolution is given at the same time (dpi or 'dots per centimeter'), I really don't get it. As it is one basically only sets an aspect ratio or not?
If anything I want to be able to size and export my figures using exact dimensions (cm/inch) At a given resolution!

I never understood why matlab doesn't offer an export resolution for their figures. I am now using your 'fig' function to create the proper aspect ration and use 'export_fig' (-r300) from the fileexchange here to export at a given resolution.
Ideally this would be fused togeter with export_fig

Obviously one wants to export most figures as a vector graphic where resolution plays no role, but that can't be done with all figures :)

26 Mar 2013 Nicholas

Hi, very good application. One question that I have is the following. Is it possible to create a figure of lets say 640x480 pixels, with a small border (i.e "border", "on") and then save it as a PNG with resolution 300 dpi ??

12 Mar 2013 Abdelbaset Hamza

Very nice work, thank you!

I have a question, in the header of the function, did you mean to switch these two dimensions, or this is the correct one:

% Note: For IEEE journals, one column wide standard is 8.5cm (3.5in), and two-column width standard is 17cm (7 1/16 in)

02 Feb 2013 Felipe G. Nievinski  
03 Oct 2012 Yiping

good

02 Aug 2012 Christine A.

Very nice! Works perfect!!

12 Jun 2012 Reza

Please drop me an email with a minimal example that reproduces your issue.

tnx

09 Jun 2012 Ben

Crashed when having subplots. Any suggestion?

14 May 2012 Reza

Hi,

This issue should be directly addressed in export_fig, as let's say a 'soft-crop'.

However, in order to keep some white space around the graphs, a quick fix could be fig('border','on',...) along with export_fig -nocrop.

cheers

14 May 2012 Hin Kwan Wong

Hi. I second Tobias Lamour 's recommendation of an optional thin border for compatibility with export_fig, especially with graphs that has axis-labels.

Please see a figure with xlabel being cropped after using fig and export_fig:
http://www.mediafire.com/?abvhzwa5wmthnai

01 May 2012 Matthew Barnes  
17 Apr 2012 Tobias Lamour

Hi Reza,

Thanks for the update. are you able to specify you changes you have made in more detail?
Thanks,
Tobi

17 Apr 2012 Reza

A new version is available with bugs fixes. This version has been revised for future updates. Drop me an email for any question.

26 Sep 2011 Tobias Lamour

Hi Reza,
Do you have, or anyone else, the time to address two things or provide information towards a practical solution or workaround:

1: Is there a possibility to add a small portion of white-space only on the right-hand side of the figure(~1 to 5 pixel).
The reason I am asking for this is that if you use export_fig it does clips a bit of the axes or tick marks. (Caused by Ghost script!)
(I can provide code and images to reproduce the problem!)

2: I am looking for a way to address each time calling the function a specific figure X. Example: rather fig use fig(1) similar to figure(1) so it does plot always in the same figure rather than creating a new one each time.

Many thanks for your help indeed,
Tobi

22 Sep 2011 Tobias Lamour

Reaz absolute brilliant - a great addition to export_fig indeed!

15 Jul 2011 halil sen  
28 Mar 2011 shuangou ren

Thanks, very useful by combining with export_fig.

15 Mar 2011 chris

Very helpful. Thanks!

Updates
15 Mar 2011

v1.5: No unnecessary white space around the plots. Minor bugs fixed.

15 Mar 2011

v1.5.1: Updated documentation & BSD.

27 Mar 2011

v1.5.2: Added ability to work with figure handles such as h=fig(h,...). Optimized default property values.

30 Mar 2011

v1.5.3: Added the ability to accept all the Matlab figure(...) options. Optimized error handling.

17 Apr 2012

v1.6: Bugs fixed. Revised for future updates.

14 May 2012

v1.6.5: Added an optional parameter that keeps some white-space around the graphs: fig('border', 'on',...).

Contact us