Wednesday, August 16, 2017

python matplotlib save svg with text as text

https://stackoverflow.com/questions/14600948/matplotlib-plot-outputs-text-as-paths-and-cannot-be-converted-to-latex-by-inks

The matplotlib documentation in http://matplotlib.org/users/customizing.html states that the default value for the parameter svg.fonttype is 'path', which means that characters will be converted to paths when exporting to svg format.
All I needed to do was add the following line in my script:
matplotlib.rcParams['svg.fonttype'] = 'none'
This way all characters are embedded correctly,


Another, more permanent option, is to put
svg.fonttype : none
in your matplotlibrc (~/.config/matplotlib/matplotlibrc, for example)