matplotlib.pyplot.ginput#
- matplotlib.pyplot.ginput(n=1,timeout=30,show_clicks=True,mouse_add=MouseButton.LEFT,mouse_pop=MouseButton.RIGHT,mouse_stop=MouseButton.MIDDLE)[source]#
Blocking call to interact with a figure.
Wait until the user clicksn times on the figure, and return thecoordinates of each click in a list.
There are three possible interactions:
Add a point.
Remove the most recently added point.
Stop the interaction and return the points added so far.
The actions are assigned to mouse buttons via the argumentsmouse_add,mouse_pop andmouse_stop.
- Parameters:
- nint, default: 1
Number of mouse clicks to accumulate. If negative, accumulateclicks until the input is terminated manually.
- timeoutfloat, default: 30 seconds
Number of seconds to wait before timing out. If zero or negativewill never time out.
- show_clicksbool, default: True
If True, show a red cross at the location of each click.
- mouse_add
MouseButton
or None, default:MouseButton.LEFT
Mouse button used to add points.
- mouse_pop
MouseButton
or None, default:MouseButton.RIGHT
Mouse button used to remove the most recently added point.
- mouse_stop
MouseButton
or None, default:MouseButton.MIDDLE
Mouse button used to stop input.
- Returns:
- list of tuples
A list of the clicked (x, y) coordinates.
Notes
Note
This is thepyplot wrapper for
Figure.ginput
.The keyboard can also be used to select points in case your mousedoes not have one or more of the buttons. The delete and backspacekeys act like right-clicking (i.e., remove last point), the enter keyterminates input and any other key (not already used by the windowmanager) selects a point.