8000 Backport PR #12269 on branch v3.0.x (Add some param docs to BlockingInput methods) by meeseeksmachine · Pull Request #12280 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

Backport PR #12269 on branch v3.0.x (Add some param docs to BlockingInput methods) #12280

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
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
58 changes: 52 additions & 6 deletions lib/matplotlib/blocking_input.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,14 +155,26 @@ def key_event(self):
self.mouse_event_add(event)

def mouse_event_add(self, event):
"""Process an button-1 event (add a click if inside axes)."""
"""
Process an button-1 event (add a click if inside axes).

Parameters
----------
event : `~.backend_bases.MouseEvent`
"""
if event.inaxes:
self.add_click(event)
else: # If not a valid click, remove from event list.
BlockingInput.pop(self)

def mouse_event_stop(self, event):
"""Process an button-2 event (end blocking input)."""
"""
Process an button-2 event (end blocking input).

Parameters
----------
event : `~.backend_bases.MouseEvent`
"""
# Remove last event just for cleanliness.
BlockingInput.pop(self)
# This will exit even if not in infinite mode. This is consistent with
Expand All @@ -171,15 +183,27 @@ def mouse_event_stop(self, event):
self.fig.canvas.stop_event_loop()

def mouse_event_pop(self, event):
"""Process an button-3 event (remove the last click)."""
"""
Process an button-3 event (remove the last click).

Parameters
----------
event : `~.backend_bases.MouseEvent`
"""
# Remove this last event.
BlockingInput.pop(self)
# Now remove any existing clicks if possible.
if self.events:
self.pop(event)

def add_click(self, event):
"""Add the coordinates of an event to the list of clicks."""
"""
Add the coordinates of an event to the list of clicks.

Parameters
----------
event : `~.backend_bases.MouseEvent`
"""
self.clicks.append((event.xdata, event.ydata))
_log.info("input %i: %f, %f",
len(self.clicks), event.xdata, event.ydata)
Expand All @@ -192,7 +216,13 @@ def add_click(self, event):
self.fig.canvas.draw()

def pop_click(self, event, index=-1):
"""Remove a click (by default, the last) from the list of clicks."""
"""
Remove a click (by default, the last) from the list of clicks.

Parameters
----------
event : `~.backend_bases.MouseEvent`
"""
self.clicks.pop(index)
if self.show_clicks:
self.marks.pop(index).remove()
Expand All @@ -208,6 +238,12 @@ def pop(self, event, index=-1):
BlockingInput.pop(self, index)

def cleanup(self, event=None):
"""
Parameters
----------
event : `~.backend_bases.MouseEvent`, optional
Not used
"""
# Clean the figure.
if self.show_clicks:
for mark in self.marks:
Expand Down Expand Up @@ -246,7 +282,13 @@ def pop_click(self, event, index=-1):
self.button3(event)

def button1(self, event):
"""Process an button-1 event (add a label to a contour)."""
"""
Process an button-1 event (add a label to a contour).

Parameters
----------
event : `~.backend_bases.MouseEvent`
"""
# Shorthand
if event.inaxes == self.cs.ax:
self.cs.add_label_near(event.x, event.y, self.inline,
Expand All @@ -263,6 +305,10 @@ def button3(self, event):
Unfortunately, if one is doing inline labels, then there is currently
no way to fix the broken contour - once humpty-dumpty is broken, he
can't be put back together. In inline mode, this does nothing.

Parameters
----------
event : `~.backend_bases.MouseEvent`
"""
if self.inline:
pass
Expand Down
0