versión (565 KB) por Daniel J O'Shea
Cross-platform WYSIWYG figure export from Matlab to SVG, PDF, PNG, EPS preserving transparency

1,3K descargas

Actualizada 10 May 2022

De GitHub

Ver licencia en GitHub

SaveFigure is a Matlab utility which provides aesthetically pleasing figure export which provides a few essential features not present in Matlab's built in figure export or any known utility on the FileExchange:
- instant export to multiple formats, including PDF, SVG, EPS, PNG, while ensuring that all formats look identical
identical output on multiple platforms (Linux and MacOS currently supported, Windows support should not be difficult to add, contact me if interested)
- preserves alpha blending and transparency on patches, lines, markers, etc.
- sets or preserves nicely rendered fonts (specified in options)
- preserves vector graphics
I've found the outputs to be more consistent, more faithful to the on-screen displayed figure. Please note that this submission includes code copied wholesale from Juerg Schwizer, Oliver Woodford, Yair Altman, and Peder Axensten.

For Linux:
sudo apt-get install inkscape imagemagick

For Mac, install homebrew [ ] and then run:
brew install inkscape imagemagick
(you could also do "brew cask install inkscape" instead).

For Windows: doesn't work yet, but I should hopefully be able to figure this out soon. If you'd like to help, I'd be happy to accept pull requests on github!

See for more details and to file issues.

To achieve faithful, WYSIWYG vector reproduction of Matlab figures, we generate SVGs, then convert to PDF using Inkscape, and then to PNG and EPS if requested using ImageMagick's convert utility. I've found that convert rarely does a nice job going from SVG to PDF directly, though this could simply be a matter of setting the correct flags. So Matlab is only responsible for generating the SVG. For newer versions of Matlab (R2014a or newer), saveFigure uses Matlab's new internal SVG engine, i.e. print -dsvg, which faithfully reproduces Matlab figures as SVG. For older versions, the code for generating SVGs is essentially a nice wrapper around Juerg Schwizer's plot2svg utility, with a few minor tweaks. The advantage of this approach is that we have complete control of figure output and appearance; the disadvantage is that it requires a complete reconstruction of the figure as an SVG. Consequently, it may not perfectly reproduce the figure in all instances, but it does a fairly decent job.

Citar como

Daniel J O'Shea (2022). matlab-save-figure (, GitHub. Recuperado .

Compatibilidad con la versión de MATLAB
Se creó con R2015a
Compatible con cualquier versión
Compatibilidad con las plataformas
Windows macOS Linux

Community Treasure Hunt

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

Start Hunting!
Para consultar o informar de algún problema sobre este complemento de GitHub, visite el repositorio de GitHub.
Para consultar o informar de algún problema sobre este complemento de GitHub, visite el repositorio de GitHub.