File Exchange

image thumbnail

fig- the exact figure size and no white space

version 1.7 (3.08 KB) by

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

4.90909
13 Ratings

20 Downloads

Updated

View License

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).

Comments and Ratings (21)

arnold

arnold (view profile)

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...

Phillip

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

giovdain

arnold

arnold (view profile)

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 :)

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 ??

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)

Yiping

Yiping (view profile)

good

Christine A.

Very nice! Works perfect!!

Reza

Reza (view profile)

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

tnx

Ben

Ben (view profile)

Crashed when having subplots. Any suggestion?

Reza

Reza (view profile)

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

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

Tobias Lamour

Hi Reza,

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

Reza

Reza (view profile)

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

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

Tobias Lamour

Reaz absolute brilliant - a great addition to export_fig indeed!

halil sen

zhuhhu

zhuhhu (view profile)

Thanks, very useful by combining with export_fig.

chris

chris (view profile)

Very helpful. Thanks!

Updates

1.7

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

1.5

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

1.4

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

1.3

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

1.2

v1.5.1: Updated documentation & BSD.

1.1

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

MATLAB Release
MATLAB 7.10 (R2010a)

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video