matplotlib 3.5.1

NotesParameters

Place vertices with each mouse click, and make the selection by completing the polygon (clicking on the first vertex). Once drawn individual vertices can be moved by clicking and dragging with the left mouse button, or removed by clicking the right mouse button.

In addition, the following modifier keys can be used:

For the selector to remain responsive you must keep a reference to it.

Notes

If only one point remains after removing points, the selector reverts to an incomplete state and you can start drawing a new polygon from the existing point.

Parameters

ax : `~matplotlib.axes.Axes`

The parent axes for the widget.

onselect : function

When a polygon is completed or modified after completion, the onselect function is called and passed a list of the vertices as (xdata, ydata) tuples.

useblit : bool, default: False

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

props : dict, optional

Properties with which the line is drawn, see matplotlib.lines.Line2D for valid properties. Default:

dict(color='k', linestyle='-', linewidth=2, alpha=0.5)

handle_props : dict, optional

Artist properties for the markers drawn at the vertices of the polygon. 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 color property in props.

grab_range : float, default: 10

A vertex is selected (to complete the polygon or to move a vertex) if the mouse click is within grab_range pixels of the vertex.

Select a polygon region of an axes.

Examples

/gallery/widgets/polygon_selector_demo

See :

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#3339
type: <class 'type'>
Commit: