-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
[Bug]: subfigure artists not drawn interactively #28384
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Very likely the issue is that |
Huh. I never use interactive mode so didn't test that! Seems a pretty big oversight. Thanks for finding. |
diff --git a/lib/matplotlib/figure.py b/lib/matplotlib/figure.py
index 9139b2ed26..9f764cc233 100644
--- a/lib/matplotlib/figure.py
+++ b/lib/matplotlib/figure.py
@@ -1636,6 +1636,8 @@ default: %(va)s
sf = SubFigure(self, subplotspec, **kwargs)
self.subfigs += [sf]
sf._remove_method = self.subfigs.remove
+ sf.stale_callback = _stale_figure_callback
+ self.stale = True
return sf
def sca(self, a):
is the fix. I don't have time right now to add a test etc. I'll try to get to it later today but will not be at all angry if someone takes over. |
@tacaswell does it matter that that callback will currently only set the root figure to stale and not any intermediate subfigures when they are nested? If it does matter, we can just wait for #28177 and then update the callback to work on |
Full disclosure: this is how far I got Currently the last line of the test fails. I tried and failed to create an example to show that this matters. Sorry, I probably should have commented right after I did this to avoid duplicating effort. |
Ah, no worries. I was feeling guilty that my initial comment had too little detail and I was wasting your time digging! I think waiting for #28177 to land might make sense, but it is not critical as either way, the thing that triggers the automatic re-rendering is the stale state of the top-level figure (via matplotlib/lib/matplotlib/_pylab_helpers.py Lines 124 to 131 in b19794e
matplotlib/lib/matplotlib/pyplot.py Line 298 in b19794e
matplotlib/lib/matplotlib/pyplot.py Lines 1062 to 1063 in b19794e
|
Thanks @tacaswell! So, when the top |
Bug summary
When artists are added to a subfigure in interactive mode, they do not appear until I force a draw by resizing the window.
Code for reproduction
Actual outcome
Apparently empty figure

Expected outcome
If I resize the window, the artists appear

Additional information
No response
Operating system
Ubuntu
Matplotlib Version
main
Matplotlib Backend
QtAgg and TkAgg
Python version
3.12.3
Jupyter version
No response
Installation
git checkout
The text was updated successfully, but these errors were encountered: