mpl_interactions.widgets.scatter_selector

class scatter_selector(ax, x, y, pickradius=5, which_button=1, **kwargs)[source]

Bases: matplotlib.widgets.AxesWidget

A widget for selecting a point in a scatter plot. callback will receive (index, (x, y))

Attributes
active

Is the widget active?

Methods

connect_event(event, callback)

Connect callback with an event.

disconnect_events()

Disconnect all events created by this widget.

get_active()

Get whether the widget is active.

ignore(event)

Return whether event should be ignored.

on_changed(func)

When a point is clicked calll func with the newly selected point

set_active(active)

Set whether the widget is active.

__init__(ax, x, y, pickradius=5, which_button=1, **kwargs)[source]

Create the scatter plot and selection machinery.

Parameters
  • ax (Axes) – The Axes on which to make the scatter plot

  • x, y (float or array-like, shape (n, )) – The data positions.

  • pickradius (float) – Pick radius, in points.

  • which_button (int, default: 1) – Where 1=left, 2=middle, 3=right

Other Parameters

**kwargs (arguments to scatter) – Other keyword arguments are passed directly to the ax.scatter command

Methods

__init__(ax, x, y[, pickradius, which_button])

Create the scatter plot and selection machinery.

connect_event(event, callback)

Connect callback with an event.

disconnect_events()

Disconnect all events created by this widget.

get_active()

Get whether the widget is active.

ignore(event)

Return whether event should be ignored.

on_changed(func)

When a point is clicked calll func with the newly selected point

set_active(active)

Set whether the widget is active.

Attributes

active

Is the widget active?

drawon

eventson

on_changed(func)[source]

When a point is clicked calll func with the newly selected point

Parameters

func (callable) – Function to call when slider is changed. The function must accept a (int, tuple(float, float)) as its arguments.

Returns

int – Connection id (which can be used to disconnect func)