Scalable Vector Graphics (SVG) Export of Figures
Editor's Note: This file was a File Exchange Pick of the Week
Scalable Vector Graphics (SVG) Export of Figures
Converts 2D & 3D Matlab plots to the scalable vector format (SVG). This format is specified by W3C (http://www.w3.org) and can be viewed and printed with internet browsers.
Added preliminary support of filter, clipping, and tickmark extensions that go beyond the Matlab functionality. SVG filters are a great tool to create stylish plots! Try it out! Before you start using this new features have a look at the tutorial.
Editors for the SVG file format can be found at http://www.inkscape.org.
Usage:
> plot2svg % opens a file dialog to plot the active figure
or
> plot2svg('myfile.svg', figure handle, pixelfiletype)
pixelfiletype = 'png' (default), 'jpg'
Supported Features
- line, patch, contour, contourf, quiver, surf, ...
- markers
- image (saved as linked png pictures)
- grouping of elements
- alpha values for patches
- subplot
- colorbar
- legend
- zoom
- reverse axes
- controls are saved as png pictures
- log axis scaling
- axis scaling factors (10^x)
- labels that contain Latex commands are interpreted (with some limitations):
\alpha, \Alpha, \beta, \Beta, ... \infity, \pm, \approx
{\it.....} for italic text
{\bf.....} for bold text
^{...} for superscript
_{...} for subscript
How to use SVG files in HTML code
<object type="image/svg+xml" data="./mySVGfile.svg" width="140" height="100"></object>
Limitations:
- Does not support figure objects that have been introduced for > Matlab R2014b
- axis scaling factors for 3D axes
- 3D plot functionality limited (depth sorting, light)
Cite As
Juerg Schwizer (2026). Scalable Vector Graphics (SVG) Export of Figures (https://github.com/jschwizer99/plot2svg/releases/tag/v1.9.0), GitHub. Retrieved .
MATLAB Release Compatibility
Platform Compatibility
Windows macOS LinuxCategories
- MATLAB > Graphics > 2-D and 3-D Plots > Vector Fields >
- Image Processing and Computer Vision > Image Processing Toolbox > Import, Export, and Conversion >
- MATLAB > Graphics > Labels and Styling > Labels and Annotations > Colorbar >
Tags
Acknowledgements
Inspired: ExportPngInkscape(filename,dpi,handle), matlab-save-figure, fig2svg, plot Lab color coordinates, error plot for lab color coordinates, Natural Gas Storage Valuation
Discover Live Editor
Create scripts with code, output, and formatted text in a single executable document.
example
src
| Version | Published | Release Notes | |
|---|---|---|---|
| 1.9.0 | See release notes for this release on GitHub: https://github.com/jschwizer99/plot2svg/releases/tag/v1.9.0 |
||
| 1.8.0.0 | - 1xn char arrays for tick labels
|
||
| 1.7.0.0 | - Fix for degree character
|
||
| 1.6.0.0 | - Bugfix for ticklabels outside of the axis limits
|
||
| 1.5.0.0 | Bugfixes and support of user requests. See 'Changes in Version 06-Mar-2010' for more information. |
||
| 1.4.0.0 | - Bug fixes for text size / line distance
|
||
| 1.3.0.0 | Improved SVG filter support, bugfixes, improved text support, more examples for the advanced filter usage. |
||
| 1.2.0.0 | Bugfixes and preliminary support of SVG filters, clipping, and improved axis tick labels. |
||
| 1.1.0.0 | Several bugfixes and better support of 3D graphics |
||
| 1.0.0.0 | Important bugfix solving the problem described in the last rating. Many thanks
|
