SaveFigure: Matlab vector figure export

版本 1.0.0.0 (564.6 KB) 作者: Daniel J O'Shea
Cross-platform WYSIWYG figure export from Matlab to SVG, PDF, PNG, EPS preserving transparency
1.3K 次下载
更新时间 2023/4/10

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 [ http://brew.sh/ ] 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 https://github.com/djoshea/matlab-save-figure 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.

引用格式

Daniel J O'Shea (2024). SaveFigure: Matlab vector figure export (https://github.com/djoshea/matlab-save-figure), GitHub. 检索来源 .

MATLAB 版本兼容性
创建方式 R2015a
兼容任何版本
平台兼容性
Windows macOS Linux
类别
Help CenterMATLAB Answers 中查找有关 Printing and Saving 的更多信息

Community Treasure Hunt

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

Start Hunting!

无法下载基于 GitHub 默认分支的版本

版本 已发布 发行说明
1.0.0.0

Updating description.

要查看或报告此来自 GitHub 的附加功能中的问题,请访问其 GitHub 仓库
要查看或报告此来自 GitHub 的附加功能中的问题,请访问其 GitHub 仓库