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

Skip to content

Switch the lasso selector to use mpl event handling, not input(). #10308

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 23, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 12 additions & 10 deletions examples/widgets/lasso_selector_demo_sgskip.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@
a lasso loop around the points on the graph. To draw, just click
on the graph, hold, and drag it around the points you need to select.
"""
from __future__ import print_function

from six.moves import input
from __future__ import print_function

import numpy as np

Expand Down Expand Up @@ -79,7 +78,6 @@ def disconnect(self):
if __name__ == '__main__':
import matplotlib.pyplot as plt

plt.ion()
# Fixing random state for reproducibility
np.random.seed(19680801)

Expand All @@ -91,11 +89,15 @@ def disconnect(self):
pts = ax.scatter(data[:, 0], data[:, 1], s=80)
selector = SelectFromCollection(ax, pts)

plt.draw()
input('Press Enter to accept selected points')
print("Selected points:")
print(selector.xys[selector.ind])
selector.disconnect()
def accept(event):
if event.key == "enter":
print("Selected points:")
print(selector.xys[selector.ind])
selector.disconnect()
ax.set_title("")
fig.canvas.draw()

fig.canvas.mpl_connect("key_press_event", accept)
ax.set_title("Press enter to accept selected points.")

# Block end of script so you can check that the lasso is disconnected.
input('Press Enter to quit')
plt.show()