i'm doing a project with Python and Tkinter. I can plot an array of data and i also implemented a function to add annotation on plot when i click with the mouse, but now i need a list of all annotation that i added. Is there any way to have that? This is my function to add annotation:
def onclick(self, event):
clicked = []
key = event.key
x = event.xdata
y = event.ydata
x_d = min(range(len(self.x_data)), key=lambda i: abs(self.x_data[i] - x))
local_coord = self.x_data[x_d - 6:x_d + 6]
x_1 = max(local_coord)
indx = np.where(self.x_data == x_1)[0][0]
y_1 = self.y_data[indx]
if key == "v":
self.ax.annotate("{0}nm".format(int(x_1)), size=25,
bbox=dict(boxstyle="round",fc="0.8"),
xy=(x_1, y_1), xycoords='data',
xytext=(x_1, y_1+50), textcoords='data',
arrowprops=dict(arrowstyle="-|>",
connectionstyle="bar,fraction=0",
))
self.canvas.draw()