A matlab figure to .eps and .tex file exporter, similar to LaPrint
Updated 4 May 2010

View License

matlabfrag is a function which exports a Matlab figure to .eps and .tex files for use in LaTeX/pdfLaTeX/LyX. It is inspired by LaPrint, but is intended to be more WYSIWYG, by respecting figure handles better.

Some of the advantages of matlabfrag compared to LaPrint are:
- Much more emphasis on WYSIWYG.
- Handles figures that need the OpenGL or Z-Buffer renderers.
- Text objects are sized correctly (such as with a legend).
- Tick labels are handled better.
- Reduced number of options (which could also be viewed as a disadvantage).
- A great user manual ;-)

To include the figures in LaTeX, pdfLaTeX and LyX I recommend the pstool package. More information can be found in the User Guide.

Please email any bug reports to me (see my account for more details). I'm unlikely to notice any bug reports posted in the comments.

This is version 0.6.16 of matlabfrag, uploaded 04-Apr-2010.
- Fixed a bug that occurred when a figure wasn't frontmost.

Cite As

Zebb Prime (2024). matlabfrag (, MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2009a
Compatible with any release
Platform Compatibility
Windows macOS Linux
Find more on Interactive Control and Callbacks in Help Center and MATLAB Answers

Community Treasure Hunt

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

Start Hunting!
Version Published Release Notes

Fixed a bug that occurred when a figure wasn't frontmost.

Documentation update: for plain LaTeX, \input should be used instead of \include.

Fixed a version checking bug which caused it to break in r2010a, and a EPS integer overflow bug.

Fixed a bug to do with blank strings, and a bug to do with baseline alignment.

Changed default painters dpi to 3200, and fixed my broken usage of inputParser.

Fixed a bug that occurred with [xyz]ticks set outside [xyz]lims.

- Added a test for empty ticks, while ticklabels are not empty.
- Added sections for Legends and the 'Unable to interpret TeX string' warning in the userguide.

- Removed AutoTick test from axis scalings, and updated the user guide to reflect this.

- Text alignment tweaks (hopefully for the better). In particular, x-tick labels should be vertically aligned better.
- Bug fixes: z-tick label alignment and no-text detection.

Fixed a bug that occurred if some (but not all) the tick labels are empty.

Fixed the horribly broken compatibility for r2007a and r2007b.

Improved alignment of negative xtick labels.
Legend callback should be suppressed during printing.

Improved tick label positioning.

Fixed some of the annoying resizing issues again.

Fixed support for rotated text when using the zbuffer and opengl renderers.

- Preliminary support for the opengl and zbuffer renderers.

- Fixed a bug that occurred when the figure being exported had no text in it.

- Better handling of axis tick labels and changed the substitution text format.
- More examples.
- Improved User Guide.