Make SVG file stretch with containing HTML element
Updated 11 Feb 2015

View License

Since R2014b, MATLAB can directly output graphics as SVG files (print -dpng). The generated figure has a fixed size. If you want to include this SVG on your website, you might want it to stretch to the width of the containing HTML element. This function edits the SVG file generated by MATLAB to do just this.
The function also fixes the fonts used: the default figure font is exported as 'SansSerif', which is not recognized by my browser (and I presume many others). The correct CSS name is 'sans-serif'. The function replaces all occurrences of the former with the latter.

Cite As

Cris Luengo (2024). svg_fix_viewbox(in_name,varargin) (, MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2014b
Compatible with any release
Platform Compatibility
Windows macOS Linux
Find more on MATLAB Report Generator 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