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

Removing a shared axes via ax.remove() leads to an error. #14911

Closed
ImportanceOfBeingErnest opened this issue Jul 29, 2019 · 0 comments · Fixed by #14997
Closed

Removing a shared axes via ax.remove() leads to an error. #14911

ImportanceOfBeingErnest opened this issue Jul 29, 2019 · 0 comments · Fixed by #14997
Labels
Release critical For bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions.
Milestone

Comments

@ImportanceOfBeingErnest
Copy link
Member

Bug report

Bug summary

removing a shared axes via ax.remove() leads to an error.

This bisects to "Fix locator/formatter setting when removing shared Axes" #13983 (in current master, targeted for 3.2) which initially headed out to make the situation of removing a shared axes better, fixing #12853, but apparently the test doesn't capture the below simple case.

Hence marking as release critical for 3.2, in order not to release this bug.

Code for reproduction

import matplotlib.pyplot as plt

fig, axs = plt.subplots(2, sharex=True)

axs[0].remove()

plt.show()

Actual outcome

Traceback (most recent call last):
  File "d:\***\matplotlib\lib\matplotlib\backends\backend_qt5.py", line 488, in _draw_idle
    self.draw()
  File "d:\***\matplotlib\lib\matplotlib\backends\backend_agg.py", line 396, in draw
    self.figure.draw(self.renderer)
  File "d:\***\matplotlib\lib\matplotlib\artist.py", line 38, in draw_wrapper
    return draw(artist, renderer, *args, **kwargs)
  File "d:\***\matplotlib\lib\matplotlib\figure.py", line 1722, in draw
    renderer, self, artists, self.suppressComposite)
  File "d:\***\matplotlib\lib\matplotlib\image.py", line 136, in _draw_list_compositing_images
    a.draw(renderer)
  File "d:\***\matplotlib\lib\matplotlib\artist.py", line 38, in draw_wrapper
    return draw(artist, renderer, *args, **kwargs)
  File "d:\***\matplotlib\lib\matplotlib\axes\_base.py", line 2622, in draw
    mimage._draw_list_compositing_images(renderer, self, artists)
  File "d:\***\matplotlib\lib\matplotlib\image.py", line 136, in _draw_list_compositing_images
    a.draw(renderer)
  File "d:\***\matplotlib\lib\matplotlib\artist.py", line 38, in draw_wrapper
    return draw(artist, renderer, *args, **kwargs)
  File "d:\***\matplotlib\lib\matplotlib\axis.py", line 1227, in draw
    ticks_to_draw = self._update_ticks()
  File "d:\***\matplotlib\lib\matplotlib\axis.py", line 1103, in _update_ticks
    major_locs = self.get_majorticklocs()
  File "d:\***\matplotlib\lib\matplotlib\axis.py", line 1348, in get_majorticklocs
    return self.major.locator()
  File "d:\***\matplotlib\lib\matplotlib\ticker.py", line 2032, in __call__
    return self.tick_values(vmin, vmax)
  File "d:\***\matplotlib\lib\matplotlib\ticker.py", line 2040, in tick_values
    locs = self._raw_ticks(vmin, vmax)
  File "d:\***\matplotlib\lib\matplotlib\ticker.py", line 1979, in _raw_ticks
    nbins = np.clip(self.axis.get_tick_space(),
  File "d:\***\matplotlib\lib\matplotlib\axis.py", line 2193, in get_tick_space
    length = ((ends[1][0] - ends[0][0]) / self.axes.figure.dpi) * 72
AttributeError: 'NoneType' object has no attribute 'dpi'

Expected outcome

A plot with the first axes removed, as would be achieved with the same code running in 3.1

Matplotlib version

  • Operating system: Win 8.1
  • Matplotlib version: current master
  • Matplotlib backend (print(matplotlib.get_backend())): Qt5Agg
  • Python version: 3.6
@ImportanceOfBeingErnest ImportanceOfBeingErnest added the Release critical For bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions. label Jul 29, 2019
@ImportanceOfBeingErnest ImportanceOfBeingErnest added this to the v3.2.0 milestone Jul 29, 2019
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.

1 participant