Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ps.useafm and axes.unicode_minus are incompatible #9127

Closed
anntzer opened this issue Aug 30, 2017 · 0 comments · Fixed by #14484
Closed

ps.useafm and axes.unicode_minus are incompatible #9127

anntzer opened this issue Aug 30, 2017 · 0 comments · Fixed by #14484
Milestone

Comments

@anntzer
Copy link
Contributor

anntzer commented Aug 30, 2017

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:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants