Unlike LassoSelector, this must be initialized with a starting The selected path can be used in conjunction withĬontains_point to select data points from an image. Lasso ( ax, xy, callback = None, useblit = True ) ¶ "center": Make the initial point the center of the shape,ĭraw_shape ( extents ) ¶ class matplotlib.widgets."square": Makes the shape square, default: "shift"."clear": Clear the current shape, default: "escape"."move": Move the existing shape, default: no modifier.Keyboard modifiers which affect the widget's behavior. Whether to draw a set of handles that allow interaction with the Properties with which the interactive handles are drawn. maxdist float, default: 10ĭistance in pixels within which the interactive tool handles can be button MouseButton, list of MouseButton, default: all buttonsīutton(s) that trigger rectangle selection. Whether to interpret minspanx and minspany in data or in pixelĬoordinates. onselect functionĪ callback function that is called after a selection is completed.ĭict ( facecolor = "red", edgecolor = "black", alpha = 0.2, fill = True ) spancoords, default: "data" mpl_connect ( 'key_press_event', toggle_selector ) plt. ES = EllipseSelector ( ax, onselect, drawtype = 'line' ) fig. active : print ( 'EllipseSelector activated.' ) toggle_selector. active : print ( 'EllipseSelector deactivated.' ) toggle_selector. button ) def toggle_selector ( event ): print ( ' Key pressed.' ) if event. ydata )) print ( 'used button : ', eclick. ydata )) print ( 'endposition : ( %f, %f )' % ( erelease. Import numpy as np import matplotlib.pyplot as plt from matplotlib.widgets import EllipseSelector def onselect ( eclick, erelease ): "eclick and erelease are matplotlib events at press and release." print ( 'startposition: ( %f, %f )' % ( eclick. EllipseSelector ( ax, onselect, drawtype = 'box', minspanx = 0, minspany = 0, useblit = False, lineprops = None, rectprops = None, spancoords = 'data', button = None, maxdist = 10, marker_props = None, interactive = False, state_modifier_keys = None ) ¶īases: įor the cursor to remain responsive you must keep a reference to it. Internal event handler to draw the cursor when the mouse moves. Internal event handler to clear the cursor. Line2D properties that control the appearance of the lines. Use blitting for faster drawing if supported by the backend. Cursor ( ax, horizOn = True, vertOn = True, useblit = False, ** lineprops ) ¶Ī crosshair cursor that spans the axes and moves with mouse cursor.įor the cursor to remain responsive you must keep a reference to it. Toggle (activate or deactivate) a check button by index.Ĭallbacks will be triggered if eventson is True. Returns a connection id, which can be used to disconnect the callback. property observers ¶ on_clicked ( func ) ¶ Return a tuple of the status (True/False) of all of the check buttons. Remove the observer with connection id cid. These lines exist forĮach box, but have set_visible(False) when its box is not checked.Īdd check buttons to instance ax. List of lines for the x's in the check boxes. labels list of Text rectangles list of Rectangle lines list of ( Line2D, Line2D) pairs CheckButtons ( ax, labels, actives = None ) ¶įor the check buttons to remain responsive you must keep aĬonnect to the CheckButtons with the on_clicked method. property observers ¶ on_clicked ( func ) ¶Ĭonnect the callback function func to button click events. Remove the callback function with connection id cid. The color of the button when the mouse is over it. The color of the button when not activated. The parameter isĭirectly forwarded to imshow. The image to place in the button, if not None. The Axes instance the button will be placed into. The color of the button when not hovering. Button ( ax, label, image = None, color = '0.85', hovercolor = '0.95' ) ¶įor the button to remain responsive you must keep a reference to it.Ĭall on_clicked to connect to the button. disconnect_events ( ) ¶ĭisconnect all events created by this widget. This should be used in lieu of _connect since thisįunction stores callback ids for later clean up. Property cids ¶ connect_event ( event, callback ) ¶Ĭonnect a callback function with an event. Object it may be garbage collected which will disconnect the callbacks. Maintains only weak-refs to the functions, which are memberįunctions of the widget. This is necessary because the callback registry To guarantee that the widget remains responsive and not garbage-collected,Ī reference to the object should be maintained by the user. Wide and tall you want your Axes to be to accommodate your widget. Matplotlib doesn't try toīe too smart with respect to layout - you will have to figure out how Instance and pass that as the first parameter. Widgets that are designed to work for any of the GUI backends.Īll of these widgets require you to predefine a