@@ -90,6 +90,7 @@ def __init__(self,
90
90
self .set_linewidth (linewidths )
91
91
self .set_linestyle (linestyles )
92
92
self .set_antialiased (antialiaseds )
93
+ self .set_pickradius (pickradius )
93
94
self .set_urls (urls )
94
95
95
96
@@ -105,7 +106,6 @@ def __init__(self,
105
106
else :
106
107
self ._uniform_offsets = offsets
107
108
108
- self ._pickradius = pickradius
109
109
self .update (kwargs )
110
110
self ._paths = None
111
111
@@ -221,26 +221,48 @@ def draw(self, renderer):
221
221
gc .restore ()
222
222
renderer .close_group (self .__class__ .__name__ )
223
223
224
+ def set_pickradius (self , pr ):
225
+ self ._pickradius = pr
226
+
227
+ def get_pickradius (self ):
228
+ return self ._pickradius
229
+
224
230
def contains (self , mouseevent ):
225
231
"""
226
232
Test whether the mouse event occurred in the collection.
227
233
228
234
Returns True | False, ``dict(ind=itemlist)``, where every
229
235
item in itemlist contains the event.
230
236
"""
231
- if callable (self ._contains ): return self ._contains (self ,mouseevent )
232
- if not self .get_visible (): return False ,{}
237
+ if callable (self ._contains ):
238
+ return self ._contains (self ,mouseevent )
239
+
240
+ if not self .get_visible ():
241
+ return False , {}
242
+
243
+ if self ._picker is True : # the Boolean constant, not just nonzero or 1
244
+ pickradius = self ._pickradius
245
+ else :
246
+ try :
247
+ pickradius = float (self ._picker )
248
+ except TypeError :
249
+ # This should not happen if "contains" is called via
250
+ # pick, the normal route; the check is here in case
251
+ # it is called through some unanticipated route.
252
+ warnings .warn (
253
+ "Collection picker %s could not be converted to float"
254
+ % self ._picker )
255
+ pickradius = self ._pickradius
233
256
234
257
transform , transOffset , offsets , paths = self ._prepare_points ()
235
258
236
259
ind = mpath .point_in_path_collection (
237
- mouseevent .x , mouseevent .y , self . _pickradius ,
260
+ mouseevent .x , mouseevent .y , pickradius ,
238
261
transform .frozen (), paths , self .get_transforms (),
239
- offsets , transOffset , len (self ._facecolors )> 0 )
240
- return len (ind )> 0 ,dict (ind = ind )
262
+ offsets , transOffset , pickradius <= 0 )
263
+
264
+ return len (ind )> 0 , dict (ind = ind )
241
265
242
- def set_pickradius (self ,pickradius ): self .pickradius = 5
243
- def get_pickradius (self ): return self .pickradius
244
266
245
267
def set_urls (self , urls ):
246
268
if urls is None :
0 commit comments