-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Fix draggable legend disappearing when picking while use_blit=True #28271
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
Fix draggable legend disappearing when picking while use_blit=True #28271
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for opening your first PR into Matplotlib!
If you have not heard from us in a week or so, please leave a new comment below and that should bring it to our attention. Most of our reviewers are volunteers and sometimes things fall through the cracks.
You can also join us on gitter for real-time discussion.
For details on testing, writing docs, and our review process, please see the developer guide
We strive to be a welcoming and open project. Please follow our Code of Conduct.
This comment was marked as outdated.
This comment was marked as outdated.
Sorry, I retract my comment, it does not seem to work reliably even with this change. |
The critical change was to place the drawing logic inside the But in which scenarios did it not work for you? I have tried testing it again with the code example provided in the original bug description and can't spot any issue |
Ah, I sorted out what happened. I changed the |
Okey I did notice that with |
lib/matplotlib/offsetbox.py
Outdated
@@ -1506,6 +1506,9 @@ def on_release(self, event): | |||
self.finalize_offset() | |||
self.got_artist = False | |||
if self._use_blit: | |||
self.ref_artist.draw( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You probably want to restore the background as well here or you will double-draw the legend (set it to have a colored and fraction alpha background to see the effect).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah yeah that's right, added the restoration!
I drink too much ☕ ! |
Hi! Did any maintainer maybe get the chance to test this? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I confirmed that this did fix the example.
Co-authored-by: Elliott Sales de Andrade <quantum.analyst@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also verified it worked!
Given that this is code we do not have unit tests for, and the docs failure is due to the config changing on main but not getting propogated to correctly (this is understood...we build the runner based on the config on the branch then manually create the merge commit to build the docs which leaves the requirements assuming a different base version of Python than the runner has) I'm going to go ahead and merge this before CI finishes. |
…picking while use_blit=True
Thank you for you work on this @vittoboa and thank you for sticking with it to find the a better solution than the initial one! Congratulations on your first merged Matplotlib PR 🎉 I hope we hear from you again. |
…271-on-v3.9.x Backport PR #28271 on branch v3.9.x (Fix draggable legend disappearing when picking while use_blit=True)
Fix for the issue #28129. When using a draggable legend with use_blit=True and picking enabled, the bug caused the whole legend to disappear once a line in the legend was clicked.