Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Backport PR #28739 on branch v3.9.x (Tweak interactivity docs wording (and fix capitalization).) #28740

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
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions galleries/users_explain/figure/event_handling.rst
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,8 @@ is created every time a mouse is pressed::

def __call__(self, event):
print('click', event)
if event.inaxes!=self.line.axes: return
if event.inaxes != self.line.axes:
return
self.xs.append(event.xdata)
self.ys.append(event.ydata)
self.line.set_data(self.xs, self.ys)
Expand All @@ -277,17 +278,19 @@ event.ydata)``. In addition to the ``LocationEvent`` attributes, it also has:
Draggable rectangle exercise
----------------------------

Write draggable rectangle class that is initialized with a
Write a draggable rectangle class that is initialized with a
`.Rectangle` instance but will move its ``xy``
location when dragged. Hint: you will need to store the original
``xy`` location of the rectangle which is stored as rect.xy and
location when dragged.

Hint: You will need to store the original
``xy`` location of the rectangle which is stored as ``rect.xy`` and
connect to the press, motion and release mouse events. When the mouse
is pressed, check to see if the click occurs over your rectangle (see
`.Rectangle.contains`) and if it does, store
the rectangle xy and the location of the mouse click in data coords.
the rectangle xy and the location of the mouse click in data coordinates.
In the motion event callback, compute the deltax and deltay of the
mouse movement, and add those deltas to the origin of the rectangle
you stored. The redraw the figure. On the button release event, just
you stored, then redraw the figure. On the button release event, just
reset all the button press data you stored as None.

Here is the solution::
Expand Down
2 changes: 1 addition & 1 deletion galleries/users_explain/figure/interactive.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
Interactive figures
===================

When working with data, interactivity can be invaluable. The pan/zoom and
Interactivity can be invaluable when exploring plots. The pan/zoom and
mouse-location tools built into the Matplotlib GUI windows are often sufficient, but
you can also use the event system to build customized data exploration tools.

Expand Down
2 changes: 1 addition & 1 deletion galleries/users_explain/figure/interactive_guide.rst
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ which would poll for new data and update the figure at 1Hz.

.. _spin_event_loop:

Explicitly spinning the event Loop
Explicitly spinning the event loop
----------------------------------

.. autosummary::
Expand Down