Skip to content

Rewrite cursor example to include speedup possibilities #15644

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

Merged
merged 1 commit into from
Jan 13, 2020

Conversation

timhoffm
Copy link
Member

@timhoffm timhoffm commented Nov 9, 2019

PR Summary

  • Cleaned up the two existing implementations a bit.
  • Hide the cross hair when the cursor leaves the Axes (IMHO more reasonable than letting it stay visible at some random position near the border).
  • Sped up the SnappingCursor by only redrawing if the indicated data point changes.
  • Added an implementation using blitting.

@timhoffm timhoffm force-pushed the cursor-demo-update branch 2 times, most recently from 7cb1770 to 013d478 Compare November 10, 2019 11:41
ax.set_title('Simple cursor')
ax.plot(x, y, 'o')
cursor = Cursor(ax)
fig.canvas.mpl_connect('on_mouse_move', cursor.mouse_move)
Copy link
Contributor

@anntzer anntzer Jan 11, 2020

Choose a reason for hiding this comment

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

cursor.on_mouse_move (below a few more times as well)

I think this could be unsgskipped? Sure the image would be static, but at least this would catch the AttributeError...

Also the event name is motion_notify_event...


For simplicity, this assumes that *x* values of he data is sorted.
Copy link
Contributor

Choose a reason for hiding this comment

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

"the data" (typo)

@anntzer anntzer merged commit 0da4c78 into matplotlib:master Jan 13, 2020
@timhoffm timhoffm added this to the v3.3.0 milestone Jan 13, 2020
@timhoffm timhoffm deleted the cursor-demo-update branch January 13, 2020 19:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants