2

I have produced the following plot using the following code

np.random.seed(1)
points = np.random.uniform(0,1, size = (1000,2)
values = np.random.uniform(-1,1, size = 1000)
plt.scatter(*points.T, c=values cmap = ListedColormap(sns.color_palette('coolwarm'))

image

Now, I would like to be able to hover the mouse over the points and see what value in values they correspond to. Obviously, I could simply use a plt.colorbar() as seen in the next image

image2

by using the following code

sp = plt.scatter(*points.T, c=values cmap = ListedColormap(sns.color_palette('coolwarm'))
plt.colorbar(sp)
plt.show()

However while you are looking at the plot, it is a bit harder to really get the values, and it would be way too messy to put labels on the points. Thus why I want to make the plot interactive. I had a look at matplotlib event handling and at the library plot.ly.

They both seem to say that the can indeed do it (for instance, look here) but none seems to explain how!

Any ideas?

Euler_Salter
  • 3,271
  • 8
  • 33
  • 74
  • There are already a lot of similar questions on this topic. [This one](https://stackoverflow.com/questions/20637113/possible-to-make-labels-appear-when-hovering-over-a-point-in-matplotlib-in-stem), [this one](https://stackoverflow.com/questions/42867400/python-show-image-upon-hovering-over-a-point), [this one](https://stackoverflow.com/questions/7908636/possible-to-make-labels-appear-when-hovering-over-a-point-in-matplotlib). It's really hard to help without knowing what you have tried already. Hence we can probably close this question as duplicate of any of those. – ImportanceOfBeingErnest Sep 28 '17 at 09:24
  • If you want to show what you have tried, and where the problem lies, one could reopen the question and help you with the actual problem. – ImportanceOfBeingErnest Sep 28 '17 at 09:29

0 Answers0