Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Interactive tooltips in matplotlib plot

Is there any way of getting interactive tooltips in a matplotlib plot? For instance, I wanted to get this scatter plot with hovering tooltips (http://mpld3.github.io/examples/scatter_tooltip.html) functionality in my python application, because they are really useful for visualizations. Unfortunately, I do not want to show this in a browser, but integrated in my own python application, is there any way to do this?

like image 274
MrPedru22 Avatar asked Nov 13 '15 15:11

MrPedru22


People also ask

Does matplotlib have interactive plots?

But did you know that it is also possible to create interactive plots with matplotlib directly, provided you are using an interactive backend? This article will look at two such backends and how they render interactivity within the notebooks, using only matplotlib.

What is interactive mode in matplotlib?

Matplotlib can be used in an interactive or non-interactive modes. In the interactive mode, the graph display gets updated after each statement. In the non-interactive mode, the graph does not get displayed until explicitly asked to do so.

Do You Need %Matplotlib inline?

So %matplotlib inline is only necessary to register this function so that it displays in the output. Running import matplotlib. pyplot as plt also registers this same function, so as of now it's not necessary to even use %matplotlib inline if you use pyplot or a library that imports pyplot like pandas or seaborn.


1 Answers

Matplotlib can only create static images and animations. If you want something interactive, then the only way you're going to achieve this is by using a module that outputs javascript. I would suggest reading about bokeh.

It is well developed and gaining a lot of traction in the python world as being a good option for creating interactive plots. Here's an example of bokeh's hovertool capability.

Unfortunately, I do not want to show this in a browser, but integrated in my own python application

I'm not sure what your "own python application" is but you're not going to have a fun time making an interactive plot outside of a browser. I would highly suggest going a webapp route using bokeh if interactivity is truly important to you.

like image 55
Austin A Avatar answered Oct 12 '22 23:10

Austin A