Skip to content

Commit 3ce591f

Browse files
committed
Fix lasso_selector_demo.py on Python 3
1 parent a720fd7 commit 3ce591f

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

examples/widgets/lasso_selector_demo.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
1+
from __future__ import print_function
2+
13
import numpy as np
24

35
from matplotlib.widgets import LassoSelector
46
from matplotlib.path import Path
57

8+
try:
9+
raw_input
10+
except NameError:
11+
# Python 3
12+
raw_input = input
13+
614

715
class SelectFromCollection(object):
816
"""Select indices from a matplotlib collection using `LassoSelector`.
@@ -65,18 +73,17 @@ def disconnect(self):
6573
plt.ion()
6674
data = np.random.rand(100, 2)
6775

68-
subplot_kw = dict(xlim=(0,1), ylim=(0,1), autoscale_on=False)
76+
subplot_kw = dict(xlim=(0, 1), ylim=(0, 1), autoscale_on=False)
6977
fig, ax = plt.subplots(subplot_kw=subplot_kw)
7078

7179
pts = ax.scatter(data[:, 0], data[:, 1], s=80)
7280
selector = SelectFromCollection(ax, pts)
7381

7482
plt.draw()
7583
raw_input('Press any key to accept selected points')
76-
print "Selected points:"
77-
print selector.xys[selector.ind]
84+
print("Selected points:")
85+
print(selector.xys[selector.ind])
7886
selector.disconnect()
7987

8088
# Block end of script so you can check that the lasso is disconnected.
8189
raw_input('Press any key to quit')
82-

0 commit comments

Comments
 (0)