BaFigExPro (v. 2.7)

Batch figure export processing with uniform styling.
3.2K Downloads
Updated 16 Dec 2010

View License

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 standard output styles, e.g.:
*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
*tight margins around the figure axes
*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

(v. 2.6)
*improved automatic margin adaptation to avoid label or outsided legend clipping when resizing figure with axes in 'position' mode ('adaptaxes' option).
*'tight' option to obtain the smallest possible margins.
*'marginfactor' option extended to allow absolute control on margins. In 6.x versions, it now helps the automatic axes adaptation.
*'eps_loose' option added to gain control on exported figure width.
*'customcode' option added to include custom code execution at different locations within the formatting process.
*'paperunits' option added.
*'locklimits' option added.
*'dsubset' option added to select subset of folders. 'fsubset' option now limited to files.
*fig2public can now be called without any parameter
*Help headers rewritten

(v. 2.7)
*default figure styles have been externalized and extended (see presetformat.m). Several options have been added to the 'base_config' parameter. To keep the old defaults, add 'old' to your 'base_config' input.
*option 'lockaxesaa' has been added to increase robustness of 'tight' margin mode.
*a few input parameter verifications have been added to help the user.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
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!

Cite As

Jonathan Rossel (2024). BaFigExPro (v. 2.7) (https://www.mathworks.com/matlabcentral/fileexchange/20813-bafigexpro-v-2-7), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2010a
Compatible with any release
Platform Compatibility
Windows macOS Linux
Categories
Find more on Big Data Processing in Help Center and MATLAB Answers
Acknowledgements

Inspired by: Exportfig, eps2xxx

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes
1.10.0.0

Handling of default figure styles improved and extended. For the rest, see the description section.

1.9.0.0

Many new options with a special focus on automatic figure margin correction to avoid label or legend clipping. Exportation of figures with tight margins and absolute dimension control is now possible. For the rest, see the description section.

1.8.0.0

bug introduced in last update corrected

1.7.0.0

See description

1.6.0.0

(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

1.5.0.0

Small bug corrected in formatfig.m, 'latexcodeonly' option added

1.4.0.0

7.x automatic resizing for slides export improved

1.3.0.0

2.1 update: corrected a bug in FORMATFIG (undefined variable "oldactpos")

1.2.0.0

2.1 update: corrected a bug in FORMATFIG. (undefined "oldactopos" variable).

1.1.0.0

The main feature of this update is the compatibility with Matlab 7.x and simple TeX inclusion code generation. For the rest, read below and check the changelog file. Comments and feedback welcome.

1.0.0.0