I am doing a scatterplot where I want to click on the individual points to do something. This is like the existing example code.
https://matplotlib.org/examples/event_handling/pick_event_demo.html
I have implemented an on_pick method
def on_pick(event):
ind = event.ind
for i in ind:
...do something here with blue or red data...
However, I am stuck because I putting multiple series (red and blue) in the same plot
fig, ax = plt.subplots()
ax.set_title('click on a point...')
line, = ax.plot(red_xs, red_ys, 'o', picker=5, color='red')
line, = ax.plot(blue_xs, blue_ys, 'o', picker=5, color='blue')
The event.ind is a collection of integers. They are indexes into a series. However, there seems to be no way to determine which series they are an index into.
There must be a way to do this. Does anyone know the trick?
Thank you Peter