-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
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
Update event handling docs. #19022
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.
On a general note (not part of this PR): Should this be a tutorial?
doc/users/event_handling.rst
Outdated
|
||
``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) |
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.
the button pressed: None, 1, 2, 3, 'up', 'down' (up and down are used for scroll events) | |
the button pressed: None or `.MouseButton` |
doc/users/event_handling.rst
Outdated
@@ -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 |
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.
`.Rectangle` instance but will move its x,y | |
`.Rectangle` instance but will move its ``xy`` |
doc/users/event_handling.rst
Outdated
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 |
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.
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.
doc/users/event_handling.rst
Outdated
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 |
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.
See above.
doc/users/event_handling.rst
Outdated
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 |
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.
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
doc/users/event_handling.rst
Outdated
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]), |
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.
Fancy using TeX?
'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.
yes to all (except for turning into a tutorial, which can be done separately) |
Much reformatting.
Remove documentation for
picker=<float>
which is deprecated in favorof
pickradius
.Add reference to default keymaps (closes #11472).
Modernize examples: use
pickradius
, usesubplots()
instead ofadd_subplot(111)
, etc.PR Summary
PR Checklist
pytest
passes).flake8
on changed files to check).flake8-docstrings
and runflake8 --docstring-convention=all
).doc/users/next_whats_new/
(follow instructions in README.rst there).doc/api/next_api_changes/
(follow instructions in README.rst there).