Last active
April 4, 2021 02:25
-
-
Save MarcoYcaza/cf1b03abfd070755a884a27b4a46d5cb to your computer and use it in GitHub Desktop.
Allow to draw points on plot
This file contains 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
import matplotlib.pyplot as plt | |
import numpy as np | |
from numpy import save | |
fig = plt.figure() | |
ax = fig.add_subplot(111) | |
ax.set_xlim([0, 10]) | |
ax.set_ylim([0, 10]) | |
points_storage=[] | |
def onclick(event): | |
print('button=%d, x=%d, y=%d, xdata=%f, ydata=%f' % | |
(event.button, event.x, event.y, event.xdata, event.ydata)) | |
plt.plot(event.xdata, event.ydata, 'o',markersize=5) | |
fig.canvas.draw() | |
points_storage.append([event.xdata, event.ydata]) | |
cid = fig.canvas.mpl_connect('button_press_event', onclick) | |
plt.show() | |
acumulado =np.asarray(points_storage) | |
np.save('puntos.npy', acumulado) | |
print(acumulado) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment