matplotlib.widgets.Lasso#

class matplotlib.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 with contains_point to select data points from an image.

Unlike LassoSelector, this must be initialized with a starting point xy, and the Lasso 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, the callback function is called and passed the vertices of the selected path.

useblitbool, default: True

Whether to use blitting for faster drawing (if supported by the backend). See the tutorial Faster rendering by using blitting for details.

props: dict, optional

Lasso line properties. See Line2D for valid properties. Default props are:

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

Added in version 3.9.

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

Examples using matplotlib.widgets.Lasso#

Lasso Demo

Lasso Demo