@@ -37,7 +37,7 @@ def __init__(self, ax, data):
3737
3838 facecolors = [d .color for d in data ]
3939 self .xys = [(d .x , d .y ) for d in data ]
40-
40+ fig = ax . figure
4141 self .collection = RegularPolyCollection (
4242 fig .dpi , 6 , sizes = (100 ,),
4343 facecolors = facecolors ,
@@ -47,6 +47,7 @@ def __init__(self, ax, data):
4747 ax .add_collection (self .collection )
4848
4949 self .cid = self .canvas .mpl_connect ('button_press_event' , self .onpress )
50+ self .ind = None
5051
5152 def callback (self , verts ):
5253 facecolors = self .collection .get_facecolors ()
@@ -60,18 +61,20 @@ def callback(self, verts):
6061 self .canvas .draw_idle ()
6162 self .canvas .widgetlock .release (self .lasso )
6263 del self .lasso
63-
64+ self . ind = ind
6465 def onpress (self , event ):
6566 if self .canvas .widgetlock .locked (): return
6667 if event .inaxes is None : return
6768 self .lasso = Lasso (event .inaxes , (event .xdata , event .ydata ), self .callback )
6869 # acquire a lock on the widget drawing
6970 self .canvas .widgetlock (self .lasso )
7071
71- data = [Datum (* xy ) for xy in rand (100 , 2 )]
72+ if 0 :
73+
74+ data = [Datum (* xy ) for xy in rand (100 , 2 )]
7275
73- fig = figure ()
74- ax = fig .add_subplot (111 , xlim = (0 ,1 ), ylim = (0 ,1 ), autoscale_on = False )
75- lman = LassoManager (ax , data )
76+ fig = figure ()
77+ ax = fig .add_subplot (111 , xlim = (0 ,1 ), ylim = (0 ,1 ), autoscale_on = False )
78+ lman = LassoManager (ax , data )
7679
77- show ()
80+ show ()
0 commit comments