Skip to content

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

@anntzer

Description

@anntzer

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy