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

Skip to content

Commit f0231dc

Browse files
committed
Fix lasso_demo.py
svn path=/trunk/matplotlib/; revision=4877
1 parent 20755cf commit f0231dc

2 files changed

Lines changed: 9 additions & 4 deletions

File tree

examples/lasso_demo.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@ def __init__(self, ax, data):
3535

3636
self.Nxy = len(data)
3737

38-
self.facecolors = [d.color for d in data]
38+
facecolors = [d.color for d in data]
3939
self.xys = [(d.x, d.y) for d in data]
4040

4141
self.collection = RegularPolyCollection(
4242
fig.dpi, 6, sizes=(100,),
43-
facecolors=self.facecolors,
43+
facecolors=facecolors,
4444
offsets = self.xys,
4545
transOffset = ax.transData)
4646

@@ -49,12 +49,13 @@ def __init__(self, ax, data):
4949
self.cid = self.canvas.mpl_connect('button_press_event', self.onpress)
5050

5151
def callback(self, verts):
52+
facecolors = self.collection.get_facecolors()
5253
ind = nonzero(points_inside_poly(self.xys, verts))[0]
5354
for i in range(self.Nxy):
5455
if i in ind:
55-
self.facecolors[i] = Datum.colorin
56+
facecolors[i] = Datum.colorin
5657
else:
57-
self.facecolors[i] = Datum.colorout
58+
facecolors[i] = Datum.colorout
5859

5960
self.canvas.draw_idle()
6061
self.canvas.widgetlock.release(self.lasso)

lib/matplotlib/collections.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,10 @@ def set_facecolor(self, c):
275275

276276
set_facecolors = set_facecolor
277277

278+
def get_facecolor(self):
279+
return self._facecolors
280+
get_facecolors = get_facecolor
281+
278282
def set_edgecolor(self, c):
279283
"""
280284
Set the edgecolor(s) of the collection. c can be a matplotlib color

0 commit comments

Comments
 (0)