Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Fix lasso_selector_demo.py on Python 3 #977

Merged
merged 1 commit into from

3 participants

@cgohlke

No description provided.

@pelson
Collaborator

+1

@mdboom mdboom merged commit d02d5ca into matplotlib:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jun 30, 2012
  1. @cgohlke
This page is out of date. Refresh to see the latest.
Showing with 11 additions and 4 deletions.
  1. +11 −4 examples/widgets/lasso_selector_demo.py
View
15 examples/widgets/lasso_selector_demo.py
@@ -1,8 +1,16 @@
+from __future__ import print_function
+
import numpy as np
from matplotlib.widgets import LassoSelector
from matplotlib.path import Path
+try:
+ raw_input
+except NameError:
+ # Python 3
+ raw_input = input
+
class SelectFromCollection(object):
"""Select indices from a matplotlib collection using `LassoSelector`.
@@ -65,7 +73,7 @@ def disconnect(self):
plt.ion()
data = np.random.rand(100, 2)
- subplot_kw = dict(xlim=(0,1), ylim=(0,1), autoscale_on=False)
+ subplot_kw = dict(xlim=(0, 1), ylim=(0, 1), autoscale_on=False)
fig, ax = plt.subplots(subplot_kw=subplot_kw)
pts = ax.scatter(data[:, 0], data[:, 1], s=80)
@@ -73,10 +81,9 @@ def disconnect(self):
plt.draw()
raw_input('Press any key to accept selected points')
- print "Selected points:"
- print selector.xys[selector.ind]
+ print("Selected points:")
+ print(selector.xys[selector.ind])
selector.disconnect()
# Block end of script so you can check that the lasso is disconnected.
raw_input('Press any key to quit')
-
Something went wrong with that request. Please try again.