is there a way to retrieve all the annotations mplcursors place on the plot. i want to pickle these and load back later to display on the plot. i have tried going through all items on ax through ax.get_children() but it did not give me the list of annotation.
below is mplcursors example that has two cursors and displays annotation when user click on the data point markers.
import matplotlib.pyplot as plt
import mplcursors
x1 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
x2 = [0, 2, 4, 6, 8, 10, 12, 14, 16, 18]
fig, ax = plt.subplots()
ax.set_title("Hover to see coordinates. Left click to\npersist and drag. Right click to remove.")
scatter1 = ax.scatter(x1, x1)
scatter2 = ax.scatter(x2, x2)
cursor1 = mplcursors.cursor(multiple=True)
cursor1.connect("add", lambda sel: sel.annotation.draggable(True))
cursor2 = mplcursors.cursor(hover=mplcursors.HoverMode.Transient)
cursor2.connect("add", lambda sel: sel.annotation.set_backgroundcolor('pink'))
plt.show()
i want to retrieve these annotations (in this case, all yellow boxes with its texts and arrows), pickle them, then load later and display on the new plot exactly how they show now. after they are placed on the new plot, i expect these to behave exactly same to pre-picking: right double click to remove, drag to move to different location on the canvas... I'm using Pickle package for pickling .
