Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

ps.useafm and axes.unicode_minus are incompatible #9127

Copy link
Copy link
Closed
@anntzer

Description

@anntzer
Issue body actions

Bug report

Bug summary

When both the ps.useafm and axes.unicode_minus rcparams are set, the use of a unicode minus e.g. in a tick label causes an exception to bubble out.

Code for reproduction

from pylab import *
rcParams.update({"ps.useafm": True, "axes.unicode_minus": False})
plt.xlim(-1, 1)  # ensure the ticker does go minus
plt.savefig("/tmp/foo.ps")

EDIT:

rcdefaults()
rcParams["ps.useafm"] = True
rcParams["axes.formatter.use_mathtext"] = True
xlim(-1, 1)
savefig("/tmp/test.ps")

also reproduces the issue

Actual outcome

Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/matplotlib/mathtext.py", line 1167, in _get_info
    symbol_name = font.get_name_char(glyph)
  File "/usr/lib/python3.6/site-packages/matplotlib/afm.py", line 456, in get_name_char
    wx, name, bbox = self._metrics[c]
KeyError: 8722

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/lib/python3.6/site-packages/matplotlib/pyplot.py", line 697, in savefig
    res = fig.savefig(*args, **kwargs)

<elided, long pyparsing traceback>

  File "/usr/lib/python3.6/site-packages/matplotlib/mathtext.py", line 2643, in symbol
    char = Char(c, self.get_state())
  File "/usr/lib/python3.6/site-packages/matplotlib/mathtext.py", line 1470, in __init__
    self._update_metrics()
  File "/usr/lib/python3.6/site-packages/matplotlib/mathtext.py", line 1477, in _update_metrics
    self.font, self.font_class, self.c, self.fontsize, self.dpi, self.math)
  File "/usr/lib/python3.6/site-packages/matplotlib/mathtext.py", line 475, in get_metrics
    info = self._get_info(font, font_class, sym, fontsize, dpi, math)
  File "/usr/lib/python3.6/site-packages/matplotlib/mathtext.py", line 1170, in _get_info
    (font.postscript_name, sym),
AttributeError: 'AFM' object has no attribute 'postscript_name'

Expected outcome

Not an exception, or possibly at least a clearer error. (It may well be the case that the issue is fundamentally unfixable, depending on how AFM fonts work (I have no idea), but at least we shouldn't bubble an AttributeError out.)

Matplotlib version

  • Operating System:
  • Matplotlib Version: 2.0.2 and master
  • Python Version: 3.6
  • Jupyter Version (if applicable):
  • Other Libraries:

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.