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?

2
  • There are already a lot of similar questions on this topic. This one, this one, this one. 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. Commented Sep 28, 2017 at 9: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. Commented Sep 28, 2017 at 9:29

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.