


I identified each scatter by their labels, then, if it is _collection0 get the points from array x, y, if it is from _collection1 get the points from x 2, y2 import matplotlib.pyplot as plt
MAKE SCATTER PLOT MATPLOTLIB HOW TO
My question is how to access the indices of the points of both scatter plots properly? Combining all the data into a single scatter plot would not work for me because I have multiple sets I need to plot with different markers and scatter does not allow for a list of markers.Īs I understood, you have to identify first which is the scatter you are clicking on, and then you use that to get the point from the right array. ('onpick3 scatter:', array(, dtype=int32), array(), array()) This is the output when I click all 4 points one by one: ('onpick3 scatter:', array(, dtype=int32), array(), array()) However, when I click on all four points, I only get indices of 0 and 1. The first set is plotted with the marker 'o', the second set is plotted with the marker 's' like this: Print('onpick3 scatter:', ind, x, y)Īx.scatter(x, y, 100, c, marker='o', picker=True)Īx.scatter(x*2, y, 50, c, marker='s', picker=True)įig.canvas.mpl_connect('pick_event', onpick3) Now, with the dataset loaded, lets import Matplotlib, decide on the features we want to visualize, and construct a scatter plot: import matplotlib. This is my code: import matplotlib.pyplot as plt However, when I add a second scatter plot, I only get indices of one of the plots upon clicking on the points. The demo works for a single scatter plot. I am trying to follow this demo on handling pick events on scatter plots.
