Skip to content

Introduce ArtistList for FigureBase#31746

Draft
rcomer wants to merge 4 commits into
matplotlib:mainfrom
rcomer:fig-artistlist
Draft

Introduce ArtistList for FigureBase#31746
rcomer wants to merge 4 commits into
matplotlib:mainfrom
rcomer:fig-artistlist

Conversation

@rcomer
Copy link
Copy Markdown
Member

@rcomer rcomer commented May 25, 2026

PR summary

At #31730 (comment) Tom said

We deprecated directly mutating the artist lists on Axes a while ago, but apparently forgot to do that on Figure as well!

This PR moves the Axes.ArtistList into the artist module and generalises it so it can work for both figures and axes. The new Figure.ArtistList subclasses that just to add the deprecated methods. I adapted the deprecated methods and their tests from #18216, where this was originally done for Axes.

Closes #31730, since now figimage explicitly uses the identity transform by default, and add_artist puts the image back into the image list. So both things from #31730 (comment) are resolved.

Currently this includes the commits from #31740 as I also modified warn_external there. Will rebase if necessary when that is merged.

AI Disclosure

I asked duck.ai how to get a class as a string, to use in the ArtistList repr self._parent.__class__.__name__.

PR checklist

rcomer added 4 commits May 23, 2026 18:56
pyside2 does not support python 3.12+
Following matplotlib#18216 for Axes artists, combine all figure artists except
axes and subfigures into a single list and deprecate modifying the lists
directly.
@github-actions github-actions Bot added topic: mplot3d GUI: Qt backend: cairo topic: axes topic: figures and subfigures CI: Run cibuildwheel Run wheel building tests on a PR CI: Run cygwin Run cygwin tests on a PR Documentation: examples files in galleries/examples Documentation: tutorials files in galleries/tutorials Documentation: devdocs files in doc/devel Documentation: user guide files in galleries/users_explain or doc/users labels May 25, 2026
@rcomer rcomer added this to the v3.12.0 milestone May 25, 2026
@rcomer
Copy link
Copy Markdown
Member Author

rcomer commented May 25, 2026

It seems I have discovered something that only works at py314 🧐

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Figure.add_artist() fails to re-render an image previously added via Figure.figimage() after .remove()

1 participant