Repository navigation
Support Matplotlib 3.12 ArtistList location - #688
Merged
argerlt merged 2 commits intoOct 13, 2026
Merged
Conversation
Matplotlib 3.12 deprecates Axes.ArtistList in favour of matplotlib.artist.ArtistList, and the deprecated class attribute can no longer be subscripted, so importing orix.plot failed with "TypeError: '_deprecated_property' object is not subscriptable". Import ArtistList from matplotlib.artist when available. Closes #686
argerlt
self-requested a review
October 8, 2026 17:41
argerlt
reviewed
Oct 8, 2026
Comment on lines
+54
to
+58
| try: # Matplotlib >= 3.12 | ||
| from matplotlib.artist import ArtistList | ||
| except ImportError: # pragma: no cover | ||
| ArtistList = maxes.Axes.ArtistList | ||
|
|
Collaborator
There was a problem hiding this comment.
For consistency, with more recent ORIX practices, please change ArtistList to mArtistList to denote it as a class inherited from matplotlib, and not an ORIX class.
try: # Matplotlib >= 3.12
from matplotlib.artist import ArtistList as mArtistList
except ImportError: # pragma: no cover
mArtistList = maxes.Axes.ArtistList
Otherwise, this is great, thank you for contributing to this project.
argerlt
approved these changes
Oct 13, 2026
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description of the change
Closes #686.
Matplotlib 3.12 moves
Axes.ArtistListtomatplotlib.artist.ArtistList(matplotlib/matplotlib#31794). On the class,Axes.ArtistListis now a deprecated property, so subscripting it instereographic_plot.pyraisesTypeError: '_deprecated_property' object is not subscriptable. That happens at import time, soimport orix.plot(and everything importing orix.crystal_map) fails.This imports
ArtistListfrommatplotlib.artistwhen it exists, falls back tomaxes.Axes.ArtistListon older Matplotlib, and uses it in the three type annotations. black then putsCOLLECTION_TYPESand the return annotation of_get_collection()on one line each. There's also a line in theFixedsection ofCHANGELOG.rst.Progress of the PR
orix.plot. The fallback branch is markedpragma: no coverbecause only one branch runs per Matplotlib version.Minimal example of the bug fix or new feature
Tested on Python 3.12 with
pytest orix/tests/test_plot: 111 passed, 13 skipped with Matplotlib 3.11.2, and the same with the 3.12.0.dev696 nightly wheel. Without the change, the nightly fails at import.For reviewers
__init__.py.section in
CHANGELOG.rst.__credits__inorix/__init__.pyand in.zenodo.json.