matplotlib 3.5.1

ParametersBackRef

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 .

Parameters

ax : `~matplotlib.axes.Axes`

The parent axes for the widget.

onselect : function

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.

minspanx : float, default: 0

Selections with an x-span less than or equal to minspanx are removed (when already existing) or cancelled.

minspany : float, default: 0

Selections with an y-span less than or equal to minspanx are removed (when already existing) or cancelled.

useblit : bool, default: False

Whether to use blitting for faster drawing (if supported by the backend).

props : dict, optional

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)

spancoords : {"data", "pixels"}, default: "data"

Whether to interpret minspanx and minspany in data or in pixel coordinates.

button : `.MouseButton`, list of `.MouseButton`, default: all buttons

Button(s) that trigger rectangle selection.

grab_range : float, default: 10

Distance in pixels within which the interactive tool handles can be activated.

handle_props : dict, optional

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.

interactive : bool, default: False

Whether to draw a set of handles that allow interaction with the widget after it is drawn.

state_modifier_keys : dict, optional

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.

drag_from_anywhere : bool, default: False

If :None:None:`True`, the widget can be moved by clicking anywhere within its bounds.

ignore_event_outside : bool, default: False

If :None:None:`True`, the event triggered outside the span selector will be ignored.

Select a rectangular region of an axes.

Examples

This example does not not appear to be valid Python Syntax
>>> import matplotlib.pyplot as plt
... 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)
This example is valid syntax, but raise an exception at execution
>>> fig.show()

See also: /gallery/widgets/rectangle_selector

See :

Back References

The following pages refer to to this document either explicitly or contain code examples using this.

matplotlib.widgets.LassoSelector matplotlib.widgets.RectangleSelector

Local connectivity graph

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


File: /matplotlib/widgets.py#2742
type: <class 'type'>
Commit: