Skip to content

Commit fe3e2b8

Browse files
committed
Use Path.contains_point instead of nxutils function.
`nxutils` is removed from master.
1 parent c668798 commit fe3e2b8

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

examples/widgets/lasso_selector_demo.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import numpy as np
22

33
from matplotlib.widgets import LassoSelector
4-
from matplotlib.nxutils import points_inside_poly
4+
from matplotlib.path import Path
55

66

77
class SelectFromCollection(object):
@@ -45,7 +45,8 @@ def __init__(self, ax, collection, alpha_other=0.3):
4545
self.ind = []
4646

4747
def onselect(self, verts):
48-
self.ind = np.nonzero(points_inside_poly(self.xys, verts))[0]
48+
path = Path(verts)
49+
self.ind = np.nonzero([path.contains_point(xy) for xy in self.xys])[0]
4950
self.fc[:, -1] = self.alpha_other
5051
self.fc[self.ind, -1] = 1
5152
self.collection.set_facecolors(self.fc)
@@ -76,6 +77,6 @@ def disconnect(self):
7677
print selector.xys[selector.ind]
7778
selector.disconnect()
7879

79-
# Block end of script so you can check that lasso is disconnected.
80+
# Block end of script so you can check that the lasso is disconnected.
8081
raw_input('Press any key to quit')
8182

0 commit comments

Comments
 (0)