Skip to content

Removal of y-shared polar axes causes crash at draw time #19989

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
anntzer opened this issue Apr 16, 2021 · 1 comment · Fixed by #20009
Closed

Removal of y-shared polar axes causes crash at draw time #19989

anntzer opened this issue Apr 16, 2021 · 1 comment · Fixed by #20009
Milestone

Comments

@anntzer
Copy link
Contributor

anntzer commented Apr 16, 2021

Bug report

Bug summary

All's in the title.

Code for reproduction

from pylab import *
ax1, ax2 = gcf().subplots(2, sharey=True, subplot_kw={"projection": "polar"}); ax2.remove(); show()

Actual outcome

Traceback (most recent call last):
Traceback (most recent call last):
  File ".../path/to/matplotlib/backends/backend_qt5.py", line 440, in _draw_idle
    self.draw()
  File "/home/antony/src/local/mplcairo/lib/mplcairo/base.py", line 269, in draw
    self.get_renderer(_ensure_cleared=True, _ensure_drawn=True)
  File "/home/antony/src/local/mplcairo/lib/mplcairo/base.py", line 261, in get_renderer
    return self._get_cached_or_new_renderer(
  File "/home/antony/src/local/mplcairo/lib/mplcairo/base.py", line 256, in _get_cached_or_new_renderer
    self.figure.draw(renderer)
  File ".../path/to/matplotlib/artist.py", line 74, in draw_wrapper
    result = draw(artist, renderer, *args, **kwargs)
  File ".../path/to/matplotlib/artist.py", line 51, in draw_wrapper
    return draw(artist, renderer, *args, **kwargs)
  File ".../path/to/matplotlib/figure.py", line 2730, in draw
    mimage._draw_list_compositing_images(
  File ".../path/to/matplotlib/image.py", line 132, in _draw_list_compositing_images
    a.draw(renderer)
  File ".../path/to/matplotlib/_api/deprecation.py", line 447, in wrapper
    return func(*inner_args, **inner_kwargs)
  File ".../path/to/matplotlib/_api/deprecation.py", line 447, in wrapper
    return func(*inner_args, **inner_kwargs)
  File ".../path/to/matplotlib/projections/polar.py", line 994, in draw
    super().draw(renderer, *args, **kwargs)
  File ".../path/to/matplotlib/artist.py", line 51, in draw_wrapper
    return draw(artist, renderer, *args, **kwargs)
  File ".../path/to/matplotlib/_api/deprecation.py", line 421, in wrapper
    return func(*inner_args, **inner_kwargs)
  File ".../path/to/matplotlib/axes/_base.py", line 3102, in draw
    mimage._draw_list_compositing_images(renderer, self, artists)
  File ".../path/to/matplotlib/image.py", line 132, in _draw_list_compositing_images
    a.draw(renderer)
  File ".../path/to/matplotlib/artist.py", line 51, in draw_wrapper
    return draw(artist, renderer, *args, **kwargs)
  File ".../path/to/matplotlib/axis.py", line 1124, in draw
    ticks_to_draw = self._update_ticks()
  File ".../path/to/matplotlib/axis.py", line 1011, in _update_ticks
    major_locs = self.get_majorticklocs()
  File ".../path/to/matplotlib/axis.py", line 1243, in get_majorticklocs
    return self.major.locator()
  File ".../path/to/matplotlib/projections/polar.py", line 432, in __call__
    return [tick for tick in self.base() if tick > rorigin]
  File ".../path/to/matplotlib/projections/polar.py", line 432, in __call__
    return [tick for tick in self.base() if tick > rorigin]
  File ".../path/to/matplotlib/ticker.py", line 2265, in __call__
    return self.tick_values(vmin, vmax)
  File ".../path/to/matplotlib/ticker.py", line 2273, in tick_values
    locs = self._raw_ticks(vmin, vmax)
  File ".../path/to/matplotlib/ticker.py", line 2212, in _raw_ticks
    nbins = np.clip(self.axis.get_tick_space(),
  File ".../path/to/matplotlib/axis.py", line 2513, in get_tick_space
    length = ((ends[1][1] - ends[0][1]) / self.axes.figure.dpi) * 72
AttributeError: 'NoneType' object has no attribute 'dpi'

Expected outcome

Normal axes removal.

Matplotlib version

  • Operating system: linux
  • Matplotlib version (import matplotlib; print(matplotlib.__version__)): head
  • Matplotlib backend (print(matplotlib.get_backend())): mplcairo
  • Python version: 39
  • Jupyter version (if applicable):
  • Other libraries:

(Note that this is a separate issue from #19988 as the root cause seems very different.)

Edit: I have a fix, but the test is a bit simpler if #19994 goes in first.

@anntzer
Copy link
Contributor Author

anntzer commented Apr 29, 2021

feel free to remilestone

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