Trouble saving svg file when plot contains special characters · Issue #8280 · matplotlib/matplotlib · GitHub
Skip to content

Trouble saving svg file when plot contains special characters #8280

Description

@mirthquake

Bug report

Bug summary

While trying to save a plot containing special characters as an SVG image, I get an error message saying the glyph cannot be converted with the encoding and may be wrong. In the produced SVG file, the special character is displayed as a rectangle with a cross. I searched a bit online and found the solution to this problem was to set svg.fonttype to 'none' in matplotlibrc. When I do this, however, it appears that matplotlibrc cannot handle the single quotes around 'none', although the default (commented out) option 'path' is in quotes. If I write just none without quotes, I continue to get the same error message.

Code for reproduction

import matplotlib.pyplot as plt
plt.rcParams['text.usetex'] = True
plt.rcParams['text.latex.preamble'] = '\usepackage{siunitx},\usepackage{libertine}'
plt.xlabel(r'$\si{\degree}$')
plt.tight_layout()
plt.savefig('plot.svg')
plt.show()

Actual outcome

plot

/usr/local/lib/python2.7/dist-packages/matplotlib/textpath.py:385: UserWarning: The glyph (176) of font (/usr/share/texmf/fonts/type1/public/cm-super/sfrm3583.pfb) cannot be converted with the encoding. Glyph may be wrong

Expected outcome

Ideally, the SVG file should contain a plot with the x-axis labeled with a degree sign.

Matplotlib version

  • Matplotlib version 2.0.0
  • Python version 2.7.12
  • Platform Linux Mint 18.1
  • Python installed from Linux Mint repos
  • Matplotlib installed using pip

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions