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

Add blitting support to button widgets#23457

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
greglucas merged 4 commits intomatplotlib:mainfromQuLogic:blit-button
Dec 29, 2022

Conversation

QuLogic
Copy link
Member

@QuLogicQuLogic commentedJul 20, 2022
edited
Loading

PR Summary

PR Checklist

Tests and Styling

  • Has pytest style unit tests (andpytest passes).
  • IsFlake 8 compliant (installflake8-docstrings and runflake8 --docstring-convention=all).

Documentation

  • New features are documented, with examples if plot related.
  • New features have an entry indoc/users/next_whats_new/ (follow instructions in README.rst there).
  • API changes documented indoc/api/next_api_changes/ (follow instructions in README.rst there).
  • Documentation is sphinx and numpydoc compliant (the docs shouldbuild without error).

@QuLogic
Copy link
MemberAuthor

QuLogic commentedJul 21, 2022
edited
Loading

As a test, you can run:

importmatplotlib.pyplotaspltfrommatplotlib._apiimportsuppress_matplotlib_deprecation_warningfrommatplotlib.widgetsimportButton,CheckButtons,RadioButtonsforuseblitin [False,True]:fig,axs=plt.subplots(10,10,constrained_layout=True)fig.suptitle(f'Button(useblit={useblit})')fig._buttons= [Button(ax,f'Test{i}',useblit=useblit)fori,axinenumerate(axs.flat)    ]forbutton_classin (CheckButtons,RadioButtons):foruseblitin [False,True]:fig,axs=plt.subplots(10,10,constrained_layout=True)fig.suptitle(f'{button_class.__name__}(useblit={useblit})')fig._buttons= [button_class(ax, [f'Test{4*i+j}'forjinrange(4)],useblit=useblit)fori,axinenumerate(axs.flat)        ]forbuttoninfig._buttons[::2]:withsuppress_matplotlib_deprecation_warning():ifisinstance(button,RadioButtons):button.circles# Trigger deprecated behaviour.else:button.linesplt.show()

which foruseblit=False takes seconds to refresh on click (or hover for plainButton), but is nearly instantaneous withuseblit=True.

@QuLogic
Copy link
MemberAuthor

Rebased to work withRadioButtons-as-scatter-plot, and also updated the above code to test both the old and new buttons.

@anntzer
Copy link
Contributor

Looks good, but perhaps this should wait for#24474 to be merged first (and blitting adapted to the new checkboxes as well)?

@@ -209,7 +214,11 @@ def _motion(self, event):
if not colors.same_color(c, self.ax.get_facecolor()):
self.ax.set_facecolor(c)
if self.drawon:
self.ax.figure.canvas.draw()
if self._useblit:
self.ax.draw_artist(self.ax)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Can you confirm that Button doesn't use copy_from_bbox/restore_region like the other two widgets because the button covers the entire axes anyways?

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Yes, and it's strictly a rectangle, socopy_from_bbox/restore_region would effectively be directly overwritten immediately.

@QuLogic
Copy link
MemberAuthor

I also wonder if the default should beTrue like the newToolHandles andSelectors were whenuseblit was added to them?

@anntzer
Copy link
Contributor

Seems reasonable.

@greglucasgreglucas merged commit5f836e5 intomatplotlib:mainDec 29, 2022
@QuLogicQuLogic deleted the blit-button branchDecember 29, 2022 21:00
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@anntzeranntzeranntzer approved these changes

@greglucasgreglucasgreglucas approved these changes

Assignees
No one assigned
Projects
None yet
Milestone
v3.7.0
Development

Successfully merging this pull request may close these issues.

3 participants
@QuLogic@anntzer@greglucas

[8]ページ先頭

©2009-2025 Movatter.jp