matplotlib.widgets.AxesWidget#

class matplotlib.widgets.AxesWidget(ax)[source]#

Bases: Widget

Widget connected to a single Axes.

To guarantee that the widget remains responsive and not garbage-collected, a reference to the object should be maintained by the user.

This is necessary because the callback registry maintains only weak-refs to the functions, which are member functions of the widget. If there are no references to the widget object it may be garbage collected which will disconnect the callbacks.

Attributes:
axAxes

The parent Axes for the widget.

canvasFigureCanvasBase

The parent figure canvas for the widget.

activebool

Is the widget active?

property canvas#
connect_event(event, callback)[source]#

Connect a callback function with an event.

This should be used in lieu of figure.canvas.mpl_connect since this function stores callback ids for later clean up.

disconnect_events()[source]#

Disconnect all events created by this widget.

ignore(event)[source]#

Return whether event should be ignored.

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

Examples using matplotlib.widgets.AxesWidget#

Lasso Demo

Lasso Demo

Annotated cursor

Annotated cursor

Buttons

Buttons

Check buttons

Check buttons

Cursor

Cursor

Select indices from a collection using polygon selector

Select indices from a collection using polygon selector

Polygon Selector

Polygon Selector

Radio Buttons

Radio Buttons

Radio Buttons Grid

Radio Buttons Grid

Image scaling using a RangeSlider

Image scaling using a RangeSlider

Rectangle and ellipse selectors

Rectangle and ellipse selectors

Slider

Slider

Snap sliders to discrete values

Snap sliders to discrete values

Span Selector

Span Selector

Textbox

Textbox