To guarantee that the selector remains responsive, keep a reference to it.
In order to turn off the SpanSelector, set span_selector.active
to False. To turn it back on, set it to True.
Press and release events triggered at the same coordinates outside the selection will clear the selector, except when ignore_event_outside=True
.
A callback function that is called after a release event and the selection is created, changed or removed. It must have the signature:
def on_select(min: float, max: float) -> Any
The direction along which to draw the span selector.
If selection is less than or equal to minspan, the selection is removed (when already existing) or cancelled.
If True, use the backend-dependent blitting features for faster canvas updates.
Dictionary of matplotlib.patches.Patch
properties. Default:
dict(facecolor='red', alpha=0.5)
Called on mouse move while the span is being selected.
If True, the span stays visible after the mouse is released. Deprecated, use interactive instead.
Whether to draw a set of handles that allow interaction with the widget after it is drawn.
The mouse buttons which activate the span selector.
Properties of the handle lines at the edges of the span. Only used when interactive is True. See matplotlib.lines.Line2D
for valid properties.
Distance in pixels within which the interactive tool handles can be activated.
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.
Visually select a min/max range on a single axis and call a function with those values.
>>> import matplotlib.pyplot as plt
... import matplotlib.widgets as mwidgets
... fig, ax = plt.subplots()
... ax.plot([1, 2, 3], [10, 50, 100])
... def onselect(vmin, vmax):
... print(vmin, vmax)
... span = mwidgets.SpanSelector(ax, onselect, 'horizontal',
... props=dict(facecolor='blue', alpha=0.5))
... fig.show()
See also: /gallery/widgets/span_selector
The following pages refer to to this document either explicitly or contain code examples using this.
matplotlib.widgets.LassoSelector
matplotlib.widgets.SpanSelector
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