Skip to content

Commit

Permalink
Merge pull request matplotlib#977 from cgohlke/patch-13
Browse files Browse the repository at this point in the history
Fix lasso_selector_demo.py on Python 3
  • Loading branch information
mdboom committed Jul 1, 2012
2 parents 6a362e4 + 3ce591f commit d02d5ca
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions examples/widgets/lasso_selector_demo.py
Original file line number Diff line number Diff line change
@@ -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`.
Expand Down Expand Up @@ -65,18 +73,17 @@ 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)
selector = SelectFromCollection(ax, pts)

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')

0 comments on commit d02d5ca

Please sign in to comment.