matplotlib.widgets._SelectorWidget#

classmatplotlib.widgets._SelectorWidget(ax,onselect=None,useblit=False,button=None,state_modifier_keys=None,use_data_coordinates=False)[source]#

Bases:AxesWidget

The base class for selector widgets.

This class provides common functionality for selector widgets,such as handling mouse and keyboard events, managing state modifier keys, etc.

The class itself is private and may be changed or removed without prior warning.However, the public API it provides to subclasses is stable and consideredpublic on the subclasses.

add_state(state)[source]#

Add a state to define the widget's behavior. See thestate_modifier_keys parameter in the constructor of the concreteselector class for details.

Parameters:
statestr

Must be a supported state of the selector. See thestate_modifier_keys parameter in the constructor of the concreteselector class for details.

Raises:
ValueError

When the state is not supported by the selector.

propertyartists#

Tuple of the artists of the selector.

clear()[source]#

Clear the selection and set the selector ready to make a new one.

connect_default_events()[source]#

Connect the major canvas events to methods.

get_visible()[source]#

Get the visibility of the selector artists.

ignore(event)[source]#

Return whetherevent should be ignored.

This method should be called at the beginning of any event callback.

on_key_press(event)[source]#

Key press event handler and validator for all selection widgets.

on_key_release(event)[source]#

Key release event handler and validator.

on_scroll(event)[source]#

Mouse scroll event handler and validator.

onmove(event)[source]#

Cursor move event handler and validator.

press(event)[source]#

Button press handler and validator.

release(event)[source]#

Button release event handler and validator.

remove_state(state)[source]#

Remove a state to define the widget's behavior. See thestate_modifier_keys parameter in the constructor of the concreteselector class for details.

Parameters:
statestr

Must be a supported state of the selector. See thestate_modifier_keys parameter in the constructor of the concreteselector class for details.

Raises:
ValueError

When the state is not supported by the selector.

set_active(active)[source]#

Set whether the widget is active.

set_handle_props(**handle_props)[source]#

Set the properties of the handles selector artist. See thehandle_props argument in the selector docstring to know whichproperties are supported.

set_props(**props)[source]#

Set the properties of the selector artist.

See theprops argument in the selector docstring to know which properties aresupported.

set_visible(visible)[source]#

Set the visibility of the selector artists.

update()[source]#

Draw using blit() or draw_idle(), depending onself.useblit.

update_background(event)[source]#

Force an update of the background.

propertyuseblit#

Return whether blitting is used (requested and supported by canvas).

Examples usingmatplotlib.widgets._SelectorWidget#

Select indices from a collection using polygon selector

Select indices from a collection using polygon selector

Polygon Selector

Polygon Selector

Rectangle and ellipse selectors

Rectangle and ellipse selectors

Span Selector

Span Selector