Skip to content

Update event handling docs. #19022

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
Nov 27, 2020
Merged

Update event handling docs. #19022

merged 1 commit into from
Nov 27, 2020

Conversation

anntzer
Copy link
Contributor

@anntzer anntzer commented Nov 26, 2020

Much reformatting.

Remove documentation for picker=<float> which is deprecated in favor
of pickradius.

Add reference to default keymaps (closes #11472).

Modernize examples: use pickradius, use subplots() instead of
add_subplot(111), etc.

PR Summary

PR Checklist

  • Has pytest style unit tests (and pytest passes).
  • Is Flake 8 compliant (run flake8 on changed files to check).
  • New features are documented, with examples if plot related.
  • Documentation is sphinx and numpydoc compliant (the docs should build without error).
  • Conforms to Matplotlib style conventions (install flake8-docstrings and run flake8 --docstring-convention=all).
  • New features have an entry in doc/users/next_whats_new/ (follow instructions in README.rst there).
  • API changes documented in doc/api/next_api_changes/ (follow instructions in README.rst there).

Copy link
Member

@timhoffm timhoffm left a comment

Choose a reason for hiding this comment

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

On a general note (not part of this PR): Should this be a tutorial?


``button``
button pressed None, 1, 2, 3, 'up', 'down' (up and down are used for scroll events)
the button pressed: None, 1, 2, 3, 'up', 'down' (up and down are used for scroll events)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
the button pressed: None, 1, 2, 3, 'up', 'down' (up and down are used for scroll events)
the button pressed: None or `.MouseButton`

@@ -162,12 +148,12 @@ Draggable rectangle exercise
----------------------------

Write draggable rectangle class that is initialized with a
:class:`~matplotlib.patches.Rectangle` instance but will move its x,y
`.Rectangle` instance but will move its x,y
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
`.Rectangle` instance but will move its x,y
`.Rectangle` instance but will move its ``xy``

print('event contains', self.rect.xy)
x0, y0 = self.rect.xy
self.press = x0, y0, event.xdata, event.ydata
self.press = self.rect.xy, event.xdata, event.ydata
Copy link
Member

Choose a reason for hiding this comment

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

This would be (x0, y0), event.xdata, event.ydata. Is this change intentional?

Edit: Seems like. But then I'd go for self.rect.xy, (event.xdata, event.ydata) so that below you have (x0, y0), (xpress, ypress) = self.press. Using a tuple only for one of the coordinates would be a bit awkward.

print('event contains', self.rect.xy)
x0, y0 = self.rect.xy
self.press = x0, y0, event.xdata, event.ydata
self.press = self.rect.xy, event.xdata, event.ydata
Copy link
Member

Choose a reason for hiding this comment

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

See above.

become additional attributes on the `.PickEvent`.

The artist's ``pickradius`` property can additionally be set to a tolerance
value (in points; there are 72 points per inch) that determines how far the
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
value (in points; there are 72 points per inch) that determines how far the
value in points (there are 72 points per inch) that determines how far the

IMHO the unit is first-class information that should not be parenthesed.

If you think that's too ambiguous, use e.g. tolerance value in units of points

ax.text(0.05, 0.9, 'mu=%1.3f\nsigma=%1.3f'%(xs[dataind], ys[dataind]),
transform=ax.transAxes, va='top')
ax.text(0.05, 0.9,
'mu=%1.3f\nsigma=%1.3f' % (xs[dataind], ys[dataind]),
Copy link
Member

Choose a reason for hiding this comment

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

Fancy using TeX?

Suggested change
'mu=%1.3f\nsigma=%1.3f' % (xs[dataind], ys[dataind]),
f'$\mu$={xs[dataind]:1.3f}\n$\sigma$={ys[dataind]:1.3f}',

Much reformatting.

Remove documentation for `picker=<float>` which is deprecated in favor
of `pickradius`.

Add reference to default keymaps.

Modernize examples: use `pickradius`, use `subplots()` instead of
`add_subplot(111)`, etc.
@anntzer
Copy link
Contributor Author

anntzer commented Nov 26, 2020

yes to all (except for turning into a tutorial, which can be done separately)

@timhoffm timhoffm added this to the v3.4.0 milestone Nov 27, 2020
@timhoffm timhoffm merged commit 329da86 into matplotlib:master Nov 27, 2020
@anntzer anntzer deleted the eh branch November 28, 2020 11:38
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.

Mention predefined keyboard shortcuts in the docs on event-handling
2 participants