{{ message }}
Add set_data for ContourSet - #32271
Open
larsoner wants to merge 2 commits into
Open
Conversation
Member
larsoner
force-pushed
the
contour-set-data
branch
from
August 31, 2026 16:34
3f53903 to
dd16a67
Compare
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.

PR summary
Covering the actual use case for MNE-Python I was investigating when I hit #32264 : needing to update contours inside an animation. This PR adds
ContourSet.set_dataso that contours can be blitted properly rather than removed and readded.This is really "issue as PR" -- I wasn't sure how many lines of code would be needed to make it work, so I figured I'd just check by implementing the changes... So I'm happy to close if this isn't wanted or refactor heavily if there is a better way, etc. It didn't end up being so bad since
_process_argscould be reused -- most of the new lines are unit tests actually. Related issues:One intentional omission is support for setting
levels. I think that should be a follow-up PR if desired -- it interacts with colorbars etc. which is a harder problem. (And maybe should be solved more generally with a.set_levelsinstead!) Also fixes a smallTriContourbug I encountered when adding a**kwargscheck (seelib/matplotlib/tri/_tricontour.py). I also added a helper to reset the object state in case theset_datafails after some attributes are already set (which can happen inside_process_args), put incbookso that other Artists could potentially use it down the line.AI Disclosure
I had Claude Opus 5 draft the code changes. I iterated through them until it looked like what I would have produced on my own (with better/more complete testing actually).
PR quality check