I’m using matplotlib in python to build a scatter plot.
suppose I have the following 2 data lists.
X=[1,2,3,4,5]
Y=[6,7,8,9,10]
then I use X as the X-axis value and Y as the Y-axis value to make a scatter plot. So I will have a picture with 5 scattering points on it, right?
Now the question: is it possible to build connection for these 5 points with the actual data. For example, when I click on one of these 5 points, it can tell me what original data I have used to make this point?
thanks in advance
Using a slightly modified version of Joe Kington’s DataCursor:
yields
You can click on any of the points and the balloon will show the underlying data values.
My slight modification to the DataCursor was to add the
snapmethod, which ensures that the data point displayed came from the original data set, rather than the location where the mouse actually clicked.If you have scipy installed, you might prefer this version of the Cursor, which makes the balloon follow the mouse (without clicking):