I have a scatter plot with multiple markers. How would I change the code so that it can still check if I click on a point on the graph or not. What would the variable line be?
line = ax.scatter(x[:10],y[:10],20, c=color_tag[:10], picker=True, marker='*')
# how would I change the code, if I would like to add this line?
line = ax.scatter(x[10:20],y[10:20],20, c=color_tag[10:20], picker=True, marker='^')
img_annotations = [...] #array of AnnotationBoxObjects
def show_ROI(event):
if line.contains(event)[0]:
ind = line.contains(event)[1]["ind"]
print('onpick3 scatter:', ind, np.take(d['x'], ind), np.take(d['y'], ind)
ab = img_annotations[ind[0]]
ab.set_visible(True)
else:
for ab in img_annotations:
ab.set_visible(False)
fig.canvas.draw_idle()
fig.canvas.mpl_connect('button_press_event', show_ROI)
plt.show()