widgets

Custom matplotlib widgets made for use in this library.

class RangeSlider(ax, label, valmin, valmax, valinit=None, valfmt=None, closedmin=True, closedmax=True, dragging=True, valstep=None, orientation='horizontal', **kwargs)[source]

Bases: mpl_interactions.widgets.SliderBase

A slider representing a floating point range.

Create a slider from valmin to valmax in axes ax. For the slider to remain responsive you must maintain a reference to it. Call on_changed() to connect to the slider event.

val

Slider value.

Type

tuple[float]

on_changed(func)[source]

When the slider value is changed call func with the new slider value

Parameters

func (callable) – Function to call when slider is changed. The function must accept a numpy array with shape (2,) float as its argument.

Returns

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

set_max(max)[source]

Set the lower value of the slider to max

Parameters

max (float)

set_min(min)[source]

Set the lower value of the slider to min

Parameters

min (float)

set_val(val)[source]

Set slider value to val

Parameters

val (tuple or arraylike of float)

class SliderBase(ax, orientation, closedmin, closedmax, valmin, valmax, valfmt, dragging, valstep)[source]

Bases: matplotlib.widgets.AxesWidget

disconnect(cid)[source]

Remove the observer with connection id cid

Parameters

cid (int) – Connection id of the observer to be removed

reset()[source]

Reset the slider to the initial value

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))

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)

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

Bases: mpl_interactions.widgets.scatter_selector

A widget for selecting a point in a scatter plot. callback will receive the index of the selected point as an argument.

on_changed(func)[source]

When a point is clicked calll func with the newly selected point’s index and position as arguments.

Parameters

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

Returns

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

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

Bases: mpl_interactions.widgets.scatter_selector

A widget for selecting a point in a scatter plot. callbacks will receive the x,y position of the selected point as arguments.

on_changed(func)[source]

When a point is clicked calll func with the newly selected point’s index as arguments.

Parameters

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

Returns

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