For the cursor to remain responsive you must keep a reference to it.
Press and release events triggered at the same coordinates outside the selection will clear the selector, except when ignore_event_outside=True
.
The parent axes for the widget.
A callback function that is called after a release event and the selection is created, changed or removed. It must have the signature:
def onselect(eclick: MouseEvent, erelease: MouseEvent)
where eclick and erelease are the mouse click and release .MouseEvent
\s that start and complete the selection.
Selections with an x-span less than or equal to minspanx are removed (when already existing) or cancelled.
Selections with an y-span less than or equal to minspanx are removed (when already existing) or cancelled.
Whether to use blitting for faster drawing (if supported by the backend).
Properties with which the rectangle is drawn. See matplotlib.patches.Patch
for valid properties. Default:
dict(facecolor='red', edgecolor='black', alpha=0.2, fill=True)
Whether to interpret minspanx and minspany in data or in pixel coordinates.
Button(s) that trigger rectangle selection.
Distance in pixels within which the interactive tool handles can be activated.
Properties with which the interactive handles (marker artists) are drawn. See the marker arguments in matplotlib.lines.Line2D
for valid properties. Default values are defined in mpl.rcParams
except for the default value of markeredgecolor
which will be the same as the edgecolor
property in props.
Whether to draw a set of handles that allow interaction with the widget after it is drawn.
Keyboard modifiers which affect the widget's behavior. Values amend the defaults.
"move": Move the existing shape, default: no modifier.
"clear": Clear the current shape, default: "escape".
"square": Make the shape square, default: "shift".
"center": Make the initial point the center of the shape, default: "ctrl".
"square" and "center" can be combined.
If :None:None:`True`
, the widget can be moved by clicking anywhere within its bounds.
If :None:None:`True`
, the event triggered outside the span selector will be ignored.
Select a rectangular region of an axes.
>>> import matplotlib.pyplot as pltThis example is valid syntax, but raise an exception at execution
... import matplotlib.widgets as mwidgets
... fig, ax = plt.subplots()
... ax.plot([1, 2, 3], [10, 50, 100])
... def onselect(eclick, erelease):
... print(eclick.xdata, eclick.ydata)
... print(erelease.xdata, erelease.ydata)
... props = dict(facecolor='blue', alpha=0.5)
... rect = mwidgets.RectangleSelector(ax, onselect, interactive=True, props=props)
>>> fig.show()
See also: /gallery/widgets/rectangle_selector
The following pages refer to to this document either explicitly or contain code examples using this.
matplotlib.widgets.LassoSelector
matplotlib.widgets.RectangleSelector
Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.
Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)
SVG is more flexible but power hungry; and does not scale well to 50 + nodes.
All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them