The BaFigExPro package provides an automatic method to export Matlab figures, with optional uniform styling. Several input/output folders can be given in a single call. The routine works both for windows and linux (tested on Matlab 6.5 and 7.x).
The package is generally used to:
- make uniform figure styling with batch processing. Styling includes font size, marker size, line width, color, legend position, ticks locking and figure dimensions.
- export figures to eps and optionally pdf, jpeg, png and tiff files. By using the eps file as an intermediate file for the other format, the typical huge white blank frame around the figures that Matlab adds when exporting in other formats is not present. The routine can also be used to export with any Matlab print format.
- prepare tex code for figure inclusion.
- automate 2 standard output styles:
*article: smaller fonts and line widths
*slides: bigger fonts and line widths
- special features:
*axes size adaptation to follow font size or figure dimension changes
*option to assure that text blocks are kept within the axes boundary
*wide number of options (recursive, subset of files, preview, ...)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
UPDATE description
(v. 2):
* 7.x compliant
* Automatic (simple) latex code generation option
* Recursive on folders
* Reset legend position option
* Matchcolorbar option (not active for 7.x)
* Interpolate option for ghostscript added
(v. 2.1)
* Bug correction
(v. 2.2)
* 7.x automatic resizing for slides export improved
(v. 2.3)
* Small bug corrected in formatfig.m
* 'latexcodeonly' option added
(v. 2.4)
*'fsubset' option added
*allow option structure input
*'eps_renderer' option added
*color handling redesigned, bw conversion greatly improved
*'recursive' option more robust
(v. 2.5)
*fig files having dots in their name are allowed
*latex interpreter restored if lost at saving
*'activeposition' and 'marginfactor' options added as resizing parameters
*'stylemap': behaviour slightly modified to allow unique Matlab style
*undock figures before formatting if necessary
(v. 2.5.1)
*bug corrected in latex interpreter restoration
General comments 6.x to 7.x:
* Figures in 7.x includes a set of hidden objects (yep, so hidden that you can't know what they are) which makes the use of "findall" a bit dangerous, or say, a good source of bugs.
* Figures generated in 6.x can be read in 7.x but DON'T BEHAVE like if they had been created in 7.x, especially when it comes to LEGENDS or COLORBARS. So, avoid processing 6.x figures on 7.x installations.
* The field that I used to link a colorbar to its axes has disappeared in 7.x. I know it still exists but can't find it. Any help would be welcome. 'ActivePositionProperty' does not care about axes-colorbar matching...
* The colorbar properties tend to be reset when saving-closing-opening a figure.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Motivations:
I was basically fed up with doing all that stuff manually. Why restart all the formatting for a presentation when the figures are already nicely prepared for an article?
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
History:
The package is based on eps2xxx by Primoz Cermelj (slightly modified) and exportfig by Ben Hinkle (greatly modified). After a thorough testing of exportfig, I saw that it was not working fine for many cases that I was needing (e.g. figures with large labels for presentations). So, I nearly rewrote it and added some cool stuff.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Usage:
Unzip the package and call fig2public. Read the help headers of the different routines! The version log is also useful... In general,
1) generate and store fig files in a folder (be minimalist in terms of format processing, always use command line calls to perform them).
2) call fig2public with the source folder and the output folder as arguments. Add all the options that you need. Many are available. The options of the different subroutines can be given directly to fig2public.
3) enjoy the output. Use the tex files in the output folders to copy-paste inclusion code.
4) you might have to define the path to ghostscript somewhere.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Bugs and "that stuff is useless":
Well, first go to the previous point, notably the "known limitations" in the version log. Then, e-mail me.
Enjoy! |