Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit cc177c1

Browse files
committed
Merge branch 'v1.0.x'
2 parents b17c400 + a213c61 commit cc177c1

2 files changed

Lines changed: 33 additions & 8 deletions

File tree

CHANGELOG

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
2011-04-03 Fixed broken pick interface to AsteriskCollection objects
2+
used by scatter. - EF
3+
14
2011-04-01 The plot directive Sphinx extension now supports all of the
25
features in the Numpy fork of that extension. These
36
include doctest formatting, an 'include-source' option, and

lib/matplotlib/collections.py

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)