@@ -92,6 +92,7 @@ def __init__(self,
9292 self .set_linewidth (linewidths )
9393 self .set_linestyle (linestyles )
9494 self .set_antialiased (antialiaseds )
95+ self .set_pickradius (pickradius )
9596 self .set_urls (urls )
9697
9798
@@ -108,7 +109,6 @@ def __init__(self,
108109 else :
109110 self ._uniform_offsets = offsets
110111
111- self ._pickradius = pickradius
112112 self .update (kwargs )
113113 self ._paths = None
114114
@@ -231,26 +231,48 @@ def draw(self, renderer):
231231 gc .restore ()
232232 renderer .close_group (self .__class__ .__name__ )
233233
234+ def set_pickradius (self , pr ):
235+ self ._pickradius = pr
236+
237+ def get_pickradius (self ):
238+ return self ._pickradius
239+
234240 def contains (self , mouseevent ):
235241 """
236242 Test whether the mouse event occurred in the collection.
237243
238244 Returns True | False, ``dict(ind=itemlist)``, where every
239245 item in itemlist contains the event.
240246 """
241- if callable (self ._contains ): return self ._contains (self ,mouseevent )
242- if not self .get_visible (): return False ,{}
247+ if callable (self ._contains ):
248+ return self ._contains (self ,mouseevent )
249+
250+ if not self .get_visible ():
251+ return False , {}
252+
253+ if self ._picker is True : # the Boolean constant, not just nonzero or 1
254+ pickradius = self ._pickradius
255+ else :
256+ try :
257+ pickradius = float (self ._picker )
258+ except TypeError :
259+ # This should not happen if "contains" is called via
260+ # pick, the normal route; the check is here in case
261+ # it is called through some unanticipated route.
262+ warnings .warn (
263+ "Collection picker %s could not be converted to float"
264+ % self ._picker )
265+ pickradius = self ._pickradius
243266
244267 transform , transOffset , offsets , paths = self ._prepare_points ()
245268
246269 ind = mpath .point_in_path_collection (
247- mouseevent .x , mouseevent .y , self . _pickradius ,
270+ mouseevent .x , mouseevent .y , pickradius ,
248271 transform .frozen (), paths , self .get_transforms (),
249- offsets , transOffset , len (self ._facecolors )> 0 )
250- return len (ind )> 0 ,dict (ind = ind )
272+ offsets , transOffset , pickradius <= 0 )
273+
274+ return len (ind )> 0 , dict (ind = ind )
251275
252- def set_pickradius (self ,pickradius ): self .pickradius = 5
253- def get_pickradius (self ): return self .pickradius
254276
255277 def set_urls (self , urls ):
256278 if urls is None :
0 commit comments