Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged

Conversation

vittoboa
Copy link
Contributor

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.

Copy link

@github-actionsgithub-actionsbot left a 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 uson gitter for real-time discussion.

For details on testing, writing docs, and our review process, please seethe developer guide

We strive to be a welcoming and open project. Please follow ourCode of Conduct.

@tacaswell

This comment was marked as outdated.

@tacaswell
Copy link
Member

Sorry, I retract my comment, it does not seem to work reliably even with this change.

@vittoboa
Copy link
ContributorAuthor

The critical change was to place the drawing logic inside theif self.got_artist part. This is because if someone clicks on a line in the legend it triggers twoon_pick events: one for generally clicking on the legend and one for clicking on the line. In the previous code it would only draw onceevt.artist == self.ref_artist was true, which was only true in the case of the legend, so the first event. Now, it handles thelegend event, which setsself.got_artist = True like before, then asself.got_artist is True it now also handles theline event.

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

@tacaswell
Copy link
Member

Ah, I sorted out what happened.

I changed thefig.canvas.draw() in the example code tofig.canvas.draw_idle() and the flashing came back.

@vittoboa
Copy link
ContributorAuthor

vittoboa commentedMay 22, 2024
edited
Loading

Ah okey I see, was that the only change? Because it seems to still work for me even when usingfig.canvas.draw_idle()

Okey I did notice that withfig.canvas.draw_idle() the legend disappears when spamming on a line. Adding draw/blit to the on_release seems to fix it

@@ -1506,6 +1506,9 @@ def on_release(self, event):
self.finalize_offset()
self.got_artist = False
if self._use_blit:
self.ref_artist.draw(
Copy link
Member

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).

Copy link
ContributorAuthor

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!

@tacaswell
Copy link
Member

... the legend disappears when spamming on a line.

I drink too much ☕ !

vittoboa reacted with laugh emoji

@vittoboa
Copy link
ContributorAuthor

Hi! Did any maintainer maybe get the chance to test this?

Copy link
Member

@QuLogicQuLogic left a 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.

vittoboa reacted with heart emoji
Co-authored-by: Elliott Sales de Andrade <quantum.analyst@gmail.com>
@tacaswelltacaswell added this to thev3.9.3 milestoneAug 22, 2024
Copy link
Member

@tacaswelltacaswell left a 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!

@tacaswell
Copy link
Member

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.

@tacaswelltacaswell merged commit28ee351 intomatplotlib:mainAug 22, 2024
32 of 40 checks passed
meeseeksmachine pushed a commit to meeseeksmachine/matplotlib that referenced this pull requestAug 22, 2024
@tacaswell
Copy link
Member

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.

vittoboa reacted with heart emoji

rcomer added a commit that referenced this pull requestSep 7, 2024
…271-on-v3.9.xBackport PR#28271 on branch v3.9.x (Fix draggable legend disappearing when picking while use_blit=True)
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@github-actionsgithub-actions[bot]github-actions[bot] left review comments

@tacaswelltacaswelltacaswell approved these changes

@QuLogicQuLogicQuLogic approved these changes

Assignees
No one assigned
Labels
None yet
Projects
Status: Waiting for author
Milestone
v3.9.3
Development

Successfully merging this pull request may close these issues.

4 participants
@vittoboa@tacaswell@QuLogic@melissawm

[8]ページ先頭

©2009-2025 Movatter.jp