Skip to content

Trouble saving svg file when plot contains special characters #8280

Closed

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

  1. changed the title [-]Trouble saving svg file[/-] [+]Trouble saving svg file when plot contains special characters[/+] on Mar 13, 2017
  2. added this to the milestone on Mar 13, 2017
  3. added a commit that references this issue on Mar 13, 2017
    cb1c72e
  4. tacaswell commented on Mar 13, 2017

    @tacaswell
    Member

    I have a fix, but not sure of other consequences of it.

  5. modified the milestones: , , on Aug 13, 2017
  6. modified the milestones: , on Oct 9, 2017
  7. github-actions commented on Apr 9, 2023

    @github-actions

    This issue has been marked "inactive" because it has been 365 days since the last comment. If this issue is still present in recent Matplotlib releases, or the feature request is still wanted, please leave a comment and this label will be removed. If there are no updates in another 30 days, this issue will be automatically closed, but you are free to re-open or create a new issue if needed. We value issue reports, and this procedure is meant to help us resurface and prioritize issues that have not been addressed yet, not make them disappear. Thanks for your help!

  8. ksunden commented on Apr 9, 2023

    @ksunden
    Member

    I do not seem to be able to recreate on current matplotlib,

    Likely resolved by some combination of #12928 + #14156. similar to #8068

  9. modified the milestones: future releases, v3.1.0 on Apr 9, 2023
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