Fix remove method for figure title and xy-labels#31075
Merged
QuLogic merged 1 commit intomatplotlib:mainfrom Feb 4, 2026
Merged
Fix remove method for figure title and xy-labels#31075QuLogic merged 1 commit intomatplotlib:mainfrom
QuLogic merged 1 commit intomatplotlib:mainfrom
Conversation
Member
Author
|
I broke the pickling. I know very little about pickling so will need some guidance here. Or anyone feel free to PR an alternative solution. |
Member
|
Oops, I wrote almost the same thing, but it also suffers from pickling problems. It looks like that can be fixed by using a partial method: diff --git a/lib/matplotlib/figure.py b/lib/matplotlib/figure.py
index 56634b2f3d..df347f876d 100644
--- a/lib/matplotlib/figure.py
+++ b/lib/matplotlib/figure.py
@@ -376,17 +376,16 @@ default: %(va)s
else:
suplab = self.text(x, y, t, **kwargs)
setattr(self, info['name'], suplab)
- orig_remove_method = suplab._remove_method
-
- # Ensure sublabel is properly removed from Figure internals.
- def _remove(label):
- orig_remove_method(label)
- setattr(self, info['name'], None)
- suplab._remove_method = _remove
+ suplab._remove_method = functools.partial(self._remove_suplabel,
+ name=info['name'])
suplab._autopos = autopos
self.stale = True
return suplab
+ def _remove_suplabel(self, label, name):
+ self.texts.remove(label)
+ setattr(self, name, None)
+
@_docstring.Substitution(x0=0.5, y0=0.98, name='super title', ha='center',
va='top', rc='title')
@_docstring.copy(_suplabels) |
Co-authored-by: Elliott Sales de Andrade <quantum.analyst@gmail.com>
d0e7e69 to
760a378
Compare
Member
Author
|
Circle-CI emailed me about successful builds on this PR. Never seen that before. |
timhoffm
approved these changes
Feb 4, 2026
Member
Also got some yesterday. This seems to be a new "feature". |
jklymak
approved these changes
Feb 4, 2026
Member
meeseeksmachine
pushed a commit
to meeseeksmachine/matplotlib
that referenced
this pull request
Feb 4, 2026
Member
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
Fixes #31073
Currently the remove method for suptitle and supx/ylabel is set within fig.text and only removes them from the list of texts. We need to additionally reset the attributes to None, consistent with their instantiation.
I have run the code from the issue and the output is consistent with having never set the suptitle.
PR checklist