Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit d02d5ca

Browse filesBrowse files
committed
Merge pull request #977 from cgohlke/patch-13
Fix lasso_selector_demo.py on Python 3
2 parents 6a362e4 + 3ce591f commit d02d5ca
Copy full SHA for d02d5ca

File tree

Expand file treeCollapse file tree

1 file changed

+11
-4
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+11
-4
lines changed

‎examples/widgets/lasso_selector_demo.py

Copy file name to clipboardExpand all lines: examples/widgets/lasso_selector_demo.py
+11-4Lines 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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.