Skip to content

BUG: Setting ticksize xx-small broken by #17348 #17670

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

Closed
larsoner opened this issue Jun 18, 2020 · 2 comments · Fixed by #17676
Closed

BUG: Setting ticksize xx-small broken by #17348 #17670

larsoner opened this issue Jun 18, 2020 · 2 comments · Fixed by #17676
Labels
Release critical For bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions.
Milestone

Comments

@larsoner
Copy link
Contributor

On commit 9909aeb this code works fine:

import matplotlib.pyplot as plt
plt.rcParams['xtick.labelsize'] = 'xx-small'
fig, ax = plt.subplots()

After #17348 (specifically 222b3ba) I get:

Traceback
>>> Traceback (most recent call last):
  File "/home/larsoner/python/matplotlib/lib/matplotlib/fontconfig_pattern.py", line 127, in parse
    self._parser.parseString(pattern)
  File "/home/larsoner/.local/lib/python3.8/site-packages/pyparsing.py", line 1945, in parseString
    raise exc
  File "/home/larsoner/.local/lib/python3.8/site-packages/pyparsing.py", line 1935, in parseString
    loc, tokens = self._parse(instring, 0)
  File "/home/larsoner/.local/lib/python3.8/site-packages/pyparsing.py", line 1836, in _parseCache
    value = self._parseNoCache(instring, loc, doActions, callPreParse)
  File "/home/larsoner/.local/lib/python3.8/site-packages/pyparsing.py", line 1675, in _parseNoCache
    loc, tokens = self.parseImpl(instring, preloc, doActions)
  File "/home/larsoner/.local/lib/python3.8/site-packages/pyparsing.py", line 4050, in parseImpl
    loc, exprtokens = e._parse(instring, loc, doActions)
  File "/home/larsoner/.local/lib/python3.8/site-packages/pyparsing.py", line 1836, in _parseCache
    value = self._parseNoCache(instring, loc, doActions, callPreParse)
  File "/home/larsoner/.local/lib/python3.8/site-packages/pyparsing.py", line 1679, in _parseNoCache
    loc, tokens = self.parseImpl(instring, preloc, doActions)
  File "/home/larsoner/.local/lib/python3.8/site-packages/pyparsing.py", line 3796, in parseImpl
    raise ParseException(instring, loc, self.errmsg, self)
pyparsing.ParseException: Expected end of text, found '-'  (at char 2), (line:1, col:3)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/larsoner/python/matplotlib/lib/matplotlib/backends/backend_qt5.py", line 471, in _draw_idle
    self.draw()
  File "/home/larsoner/python/matplotlib/lib/matplotlib/backends/backend_agg.py", line 397, in draw
    self.figure.draw(self.renderer)
  File "/home/larsoner/python/matplotlib/lib/matplotlib/artist.py", line 41, in draw_wrapper
    return draw(artist, renderer, *args, **kwargs)
  File "/home/larsoner/python/matplotlib/lib/matplotlib/figure.py", line 1681, in draw
    mimage._draw_list_compositing_images(
  File "/home/larsoner/python/matplotlib/lib/matplotlib/image.py", line 132, in _draw_list_compositing_images
    a.draw(renderer)
  File "/home/larsoner/python/matplotlib/lib/matplotlib/artist.py", line 41, in draw_wrapper
    return draw(artist, renderer, *args, **kwargs)
  File "/home/larsoner/python/matplotlib/lib/matplotlib/cbook/deprecation.py", line 410, in wrapper
    return func(*inner_args, **inner_kwargs)
  File "/home/larsoner/python/matplotlib/lib/matplotlib/axes/_base.py", line 2747, in draw
    mimage._draw_list_compositing_images(renderer, self, artists)
  File "/home/larsoner/python/matplotlib/lib/matplotlib/image.py", line 132, in _draw_list_compositing_images
    a.draw(renderer)
  File "/home/larsoner/python/matplotlib/lib/matplotlib/artist.py", line 41, in draw_wrapper
    return draw(artist, renderer, *args, **kwargs)
  File "/home/larsoner/python/matplotlib/lib/matplotlib/axis.py", line 1149, in draw
    ticks_to_draw = self._update_ticks()
  File "/home/larsoner/python/matplotlib/lib/matplotlib/axis.py", line 1007, in _update_ticks
    major_locs = self.get_majorticklocs()
  File "/home/larsoner/python/matplotlib/lib/matplotlib/axis.py", line 1268, in get_majorticklocs
    return self.major.locator()
  File "/home/larsoner/python/matplotlib/lib/matplotlib/ticker.py", line 2169, in __call__
    return self.tick_values(vmin, vmax)
  File "/home/larsoner/python/matplotlib/lib/matplotlib/ticker.py", line 2177, in tick_values
    locs = self._raw_ticks(vmin, vmax)
  File "/home/larsoner/python/matplotlib/lib/matplotlib/ticker.py", line 2116, in _raw_ticks
    nbins = np.clip(self.axis.get_tick_space(),
  File "/home/larsoner/python/matplotlib/lib/matplotlib/axis.py", line 2203, in get_tick_space
    size = self._get_tick_label_size('x') * 3
  File "/home/larsoner/python/matplotlib/lib/matplotlib/axis.py", line 1328, in _get_tick_label_size
    return mtext.FontProperties(size).get_size_in_points()
  File "/home/larsoner/python/matplotlib/lib/matplotlib/font_manager.py", line 628, in __init__
    self.set_fontconfig_pattern(family)
  File "/home/larsoner/python/matplotlib/lib/matplotlib/font_manager.py", line 840, in set_fontconfig_pattern
    for key, val in parse_fontconfig_pattern(pattern).items():
  File "/home/larsoner/python/matplotlib/lib/matplotlib/fontconfig_pattern.py", line 129, in parse
    raise ValueError(
ValueError: Could not parse font string: 'xx-small'
Expected end of text, found '-'  (at char 2), (line:1, col:3)
Traceback (most recent call last):
  File "/home/larsoner/python/matplotlib/lib/matplotlib/fontconfig_pattern.py", line 127, in parse
    self._parser.parseString(pattern)
  File "/home/larsoner/.local/lib/python3.8/site-packages/pyparsing.py", line 1945, in parseString
    raise exc
  File "/home/larsoner/.local/lib/python3.8/site-packages/pyparsing.py", line 1935, in parseString
    loc, tokens = self._parse(instring, 0)
  File "/home/larsoner/.local/lib/python3.8/site-packages/pyparsing.py", line 1836, in _parseCache
    value = self._parseNoCache(instring, loc, doActions, callPreParse)
  File "/home/larsoner/.local/lib/python3.8/site-packages/pyparsing.py", line 1675, in _parseNoCache
    loc, tokens = self.parseImpl(instring, preloc, doActions)
  File "/home/larsoner/.local/lib/python3.8/site-packages/pyparsing.py", line 4050, in parseImpl
    loc, exprtokens = e._parse(instring, loc, doActions)
  File "/home/larsoner/.local/lib/python3.8/site-packages/pyparsing.py", line 1836, in _parseCache
    value = self._parseNoCache(instring, loc, doActions, callPreParse)
  File "/home/larsoner/.local/lib/python3.8/site-packages/pyparsing.py", line 1679, in _parseNoCache
    loc, tokens = self.parseImpl(instring, preloc, doActions)
  File "/home/larsoner/.local/lib/python3.8/site-packages/pyparsing.py", line 3796, in parseImpl
    raise ParseException(instring, loc, self.errmsg, self)
pyparsing.ParseException: Expected end of text, found '-'  (at char 2), (line:1, col:3)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/larsoner/python/matplotlib/lib/matplotlib/backends/backend_qt5.py", line 471, in _draw_idle
    self.draw()
  File "/home/larsoner/python/matplotlib/lib/matplotlib/backends/backend_agg.py", line 397, in draw
    self.figure.draw(self.renderer)
  File "/home/larsoner/python/matplotlib/lib/matplotlib/artist.py", line 41, in draw_wrapper
    return draw(artist, renderer, *args, **kwargs)
  File "/home/larsoner/python/matplotlib/lib/matplotlib/figure.py", line 1681, in draw
    mimage._draw_list_compositing_images(
  File "/home/larsoner/python/matplotlib/lib/matplotlib/image.py", line 132, in _draw_list_compositing_images
    a.draw(renderer)
  File "/home/larsoner/python/matplotlib/lib/matplotlib/artist.py", line 41, in draw_wrapper
    return draw(artist, renderer, *args, **kwargs)
  File "/home/larsoner/python/matplotlib/lib/matplotlib/cbook/deprecation.py", line 410, in wrapper
    return func(*inner_args, **inner_kwargs)
  File "/home/larsoner/python/matplotlib/lib/matplotlib/axes/_base.py", line 2747, in draw
    mimage._draw_list_compositing_images(renderer, self, artists)
  File "/home/larsoner/python/matplotlib/lib/matplotlib/image.py", line 132, in _draw_list_compositing_images
    a.draw(renderer)
  File "/home/larsoner/python/matplotlib/lib/matplotlib/artist.py", line 41, in draw_wrapper
    return draw(artist, renderer, *args, **kwargs)
  File "/home/larsoner/python/matplotlib/lib/matplotlib/axis.py", line 1149, in draw
    ticks_to_draw = self._update_ticks()
  File "/home/larsoner/python/matplotlib/lib/matplotlib/axis.py", line 1007, in _update_ticks
    major_locs = self.get_majorticklocs()
  File "/home/larsoner/python/matplotlib/lib/matplotlib/axis.py", line 1268, in get_majorticklocs
    return self.major.locator()
  File "/home/larsoner/python/matplotlib/lib/matplotlib/ticker.py", line 2169, in __call__
    return self.tick_values(vmin, vmax)
  File "/home/larsoner/python/matplotlib/lib/matplotlib/ticker.py", line 2177, in tick_values
    locs = self._raw_ticks(vmin, vmax)
  File "/home/larsoner/python/matplotlib/lib/matplotlib/ticker.py", line 2116, in _raw_ticks
    nbins = np.clip(self.axis.get_tick_space(),
  File "/home/larsoner/python/matplotlib/lib/matplotlib/axis.py", line 2203, in get_tick_space
    size = self._get_tick_label_size('x') * 3
  File "/home/larsoner/python/matplotlib/lib/matplotlib/axis.py", line 1328, in _get_tick_label_size
    return mtext.FontProperties(size).get_size_in_points()
  File "/home/larsoner/python/matplotlib/lib/matplotlib/font_manager.py", line 628, in __init__
    self.set_fontconfig_pattern(family)
  File "/home/larsoner/python/matplotlib/lib/matplotlib/font_manager.py", line 840, in set_fontconfig_pattern
    for key, val in parse_fontconfig_pattern(pattern).items():
  File "/home/larsoner/python/matplotlib/lib/matplotlib/fontconfig_pattern.py", line 129, in parse
    raise ValueError(
ValueError: Could not parse font string: 'xx-small'
Expected end of text, found '-'  (at char 2), (line:1, col:3)

cc author of the PR @QuLogic and committer @timhoffm

@larsoner
Copy link
Contributor Author

I can confirm that git revert 222b3ba (followed by a conflict resolution) fixes this minimal example for me.

@tacaswell tacaswell added this to the v3.3.0 milestone Jun 18, 2020
@tacaswell tacaswell added the Release critical For bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions. label Jun 18, 2020
@tacaswell
Copy link
Member

I have a fix for this coming.

tacaswell added a commit to tacaswell/matplotlib that referenced this issue Jun 18, 2020
Passing the size positional caused it to be treated as a fontconfig
pattern.  For the relative sizes without '-' in them this formally
works and stashes the relative size in the family.  We don't actually
resolve that we can _find_ the font so this, while wrong, is not
noticed and when we ask for the size it gives us back the default
size so our size estimate was silently wrong.

In the cases where we have a '-' in the relative size the fontconfig
pattern parsing fails when we try to estimate the size.

closes  matplotlib#17670
tacaswell added a commit to tacaswell/matplotlib that referenced this issue Jun 18, 2020
Passing the size positional caused it to be treated as a fontconfig
pattern.  For the relative sizes without '-' in them this formally
works and stashes the relative size in the family.  We don't actually
resolve that we can _find_ the font so this, while wrong, is not
noticed and when we ask for the size it gives us back the default
size so our size estimate was silently wrong.

In the cases where we have a '-' in the relative size the fontconfig
pattern parsing fails when we try to estimate the size.

closes  matplotlib#17670

Co-authored-by: Elliott Sales de Andrade <quantum.analyst@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Release critical For bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants