FIX: do not replace the Axes._children list object by tacaswell · Pull Request #24677 · matplotlib/matplotlib · GitHub
Skip to content

FIX: do not replace the Axes._children list object - #24677

Merged
ksunden merged 1 commit into
matplotlib:mainfrom
tacaswell:fix/hostaxes_remove
Dec 9, 2022
Merged

FIX: do not replace the Axes._children list object#24677
ksunden merged 1 commit into
matplotlib:mainfrom
tacaswell:fix/hostaxes_remove

Conversation

@tacaswell

Copy link
Copy Markdown
Member

PR Summary

Each Artist keeps a reference to Axes._children.remove as art._remove_method. If we replace the _children instance on the Axes with a different list instance the Artists will not be updated and their remove method will refer to the wrong list. This will cause subsequent failures on the next draw because on remove we reset the art.axes and art.figure to None.

xref https://discourse.matplotlib.org/t/host-subplot-and-artist-remove/23374

PR Checklist

Documentation and Tests

  • Has pytest style unit tests (and pytest passes)
  • Documentation is sphinx and numpydoc compliant (the docs should build without error).

Each Artist keeps a reference to `Axes._children.remove` as
`art._remove_method`.  If we replace the `_children` instance on the Axes with
a different list instance the Artists will not be updated and their remove
method will refer to the wrong list.  This will cause subsequent failures on
the next draw because on remove we reset the `art.axes` and `art.figure` to
None.

xref https://discourse.matplotlib.org/t/host-subplot-and-artist-remove/23374
@tacaswell tacaswell added this to the v3.6.3 milestone Dec 9, 2022
@ksunden
ksunden merged commit 4d52a3e into matplotlib:main Dec 9, 2022
@lumberbot-app

lumberbot-app Bot commented Dec 9, 2022

Copy link
Copy Markdown

rcomer pushed a commit to rcomer/matplotlib that referenced this pull request Dec 9, 2022
…list object

Manual backport due to conflicts, which were just additional tests in
main from matplotlib#23861, so simply removed these.
tacaswell added a commit that referenced this pull request Dec 9, 2022
Backport PR #24677 on branch v3.6.x (FIX: do not replace the Axes._children list object)
@ksunden ksunden mentioned this pull request Feb 20, 2023
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants