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

Skip to content

Commit e5b6c95

Browse files
committed
Fixing picking on masked arrays (Thanks Andrew Straw)
svn path=/trunk/matplotlib/; revision=4979
1 parent 51ae9b7 commit e5b6c95

2 files changed

Lines changed: 7 additions & 3 deletions

File tree

lib/matplotlib/axes.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,8 @@ def _xy_from_y(self, y):
215215
b = self.axes.yaxis.update_units(y)
216216
if b: return npy.arange(len(y)), y, False
217217

218-
y = ma.asarray(y)
218+
if not ma.isMaskedArray(y):
219+
y = npy.asarray(y)
219220
if len(y.shape) == 1:
220221
y = y[:,npy.newaxis]
221222
nr, nc = y.shape

lib/matplotlib/lines.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@ def segment_hits(cx,cy,x,y,radius):
7575
"""Determine if any line segments are within radius of a point. Returns
7676
the list of line segments that are within that radius.
7777
"""
78+
import pdb
79+
pdb.set_trace()
80+
7881
# Process single points specially
7982
if len(x) < 2:
8083
res, = npy.nonzero( (cx - x)**2 + (cy - y)**2 <= radius**2 )
@@ -97,7 +100,7 @@ def segment_hits(cx,cy,x,y,radius):
97100
# following radius test eliminates these ambiguities.
98101
point_hits = (cx - x)**2 + (cy - y)**2 <= radius**2
99102
#if any(point_hits): print "points",xr[candidates]
100-
candidates = candidates & ~point_hits[:-1] & ~point_hits[1:]
103+
candidates = candidates & ~(point_hits[:-1] | point_hits[1:])
101104

102105
# For those candidates which remain, determine how far they lie away
103106
# from the line.
@@ -308,7 +311,7 @@ def contains(self, mouseevent):
308311
# transform in backend
309312
if len(self._xy)==0: return False,{}
310313

311-
xyt = self.get_transform().transform(self._xy)
314+
xyt = self._transformed_path.get_fully_transformed_path().vertices
312315
xt = xyt[:, 0]
313316
yt = xyt[:, 1]
314317

0 commit comments

Comments
 (0)