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

Skip to content

Commit 95a0f36

Browse files
committed
Merge pull request #599 from jrevans/working
mlab.inside_poly fix
2 parents b3a2ab7 + db2e090 commit 95a0f36

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

lib/matplotlib/mlab.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@
151151

152152
import matplotlib.cbook as cbook
153153
from matplotlib import docstring
154+
from matplotlib.path import Path
154155

155156

156157
def logspace(xmin,xmax,N):
@@ -2980,9 +2981,11 @@ def inside_poly(points, verts):
29802981
Return value is a sequence of indices into points for the points
29812982
that are inside the polygon.
29822983
"""
2983-
# PY3KTODO: Reimplement in terms of _path module
2984-
res, = np.nonzero(nxutils.points_inside_poly(points, verts))
2985-
return res
2984+
# Make a closed polygon path
2985+
poly = Path( verts )
2986+
2987+
# Check to see which points are contained withing the Path
2988+
return [ idx for idx, p in enumerate(points) if poly.contains_point(p) ]
29862989

29872990
def poly_below(xmin, xs, ys):
29882991
"""

0 commit comments

Comments
 (0)