Forked from saeedghsh/interactive_pick_dataPoint_example.py
Created
April 13, 2025 14:50
-
-
Save sefgit/244b95430c97193186b400294a38cbfd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
''' | |
Copyright (C) Saeed Gholami Shahbandi. All rights reserved. | |
Author: Saeed Gholami Shahbandi | |
This file is free software: you can redistribute it and/or modify it | |
under the terms of the GNU Lesser General Public License as published | |
by the Free Software Foundation, either version 3 of the License, or | |
(at your option) any later version. This program is distributed in | |
the hope that it will be useful, but WITHOUT ANY WARRANTY; without | |
even the implied warranty of MERCHANTABILITY or FITNESS FOR A | |
PARTICULAR PURPOSE. See the GNU Lesser General Public License for more | |
details. You should have received a copy of the GNU Lesser General | |
Public License along with this program. If not, see | |
<http://www.gnu.org/licenses/> | |
''' | |
import matplotlib.pyplot as plt | |
##### picking a data point | |
def on_pick(event): | |
print event.ind[0] | |
fig = plt.figure(figsize=(6,8)) | |
ax = fig.add_subplot(111) | |
ax.plot ([1,1,1,1], [1,2,3,4], 'ko', picker=10) | |
cid = fig.canvas.mpl_connect('pick_event', on_pick) | |
plt.axis('equal') | |
plt.tight_layout() | |
plt.show() | |
##### coordinate of the click event | |
def on_click(event): | |
print event.xdata, event.ydata | |
fig = plt.figure(figsize=(6,8)) | |
ax = fig.add_subplot(111) | |
ax.plot ([1,1,1,1], [1,2,3,4], 'ko') | |
cid = fig.canvas.mpl_connect('button_press_event', on_click) | |
plt.axis('equal') | |
plt.tight_layout() | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment