matplotlib.widgets.Lasso#

classmatplotlib.widgets.Lasso(ax,xy,callback,*,useblit=True,props=None)[source]#

Bases:AxesWidget

Selection curve of an arbitrary shape.

The selected path can be used in conjunction withcontains_point to select data points from an image.

UnlikeLassoSelector, this must be initialized with a startingpointxy, and theLasso events are destroyed upon release.

Parameters:
axAxes

The parent Axes for the widget.

xy(float, float)

Coordinates of the start of the lasso.

callbackcallable

Whenever the lasso is released, thecallback function is called andpassed the vertices of the selected path.

useblitbool, default: True

Whether to use blitting for faster drawing (if supported by thebackend). See the tutorialFaster rendering by using blittingfor details.

props: dict, optional

Lasso line properties. SeeLine2D for valid properties.Defaultprops are:

{'linestyle':'-','color':'black','lw':2}

Added in version 3.9.

onmove(event)[source]#
onrelease(event)[source]#

Examples usingmatplotlib.widgets.Lasso#

Lasso Demo

Lasso Demo