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