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(...).
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).
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...
Does not work for imshow?
It still produces boarders for me...
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 :)
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)
Very nice! Works perfect!!
Please drop me an email with a minimal example that reproduces your issue.
Crashed when having subplots. Any suggestion?
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.
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:
Thanks for the update. are you able to specify you changes you have made in more detail?
A new version is available with bugs fixes. This version has been revised for future updates. Drop me an email for any question.
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,
Reaz absolute brilliant - a great addition to export_fig indeed!
Thanks, very useful by combining with export_fig.
Very helpful. Thanks!
v1.6.5: Added an optional parameter that keeps some white-space around the graphs: fig('border', 'on',...).
v1.6: Bugs fixed. Revised for future updates.
v1.5.3: Added the ability to accept all the Matlab figure(...) options. Optimized error handling.
v1.5.2: Added ability to work with figure handles such as h=fig(h,...). Optimized default property values.
v1.5.1: Updated documentation & BSD.
v1.5: No unnecessary white space around the plots. Minor bugs fixed.
Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.