Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Matplotlib, Jupyter: Have annotation appearing when hovering over plot

I am trying to create a plot with matplotlib that has tooltip appearing when hovering hover certain elements of the charts. I want to do that in the Jupyter Notebook, with python 3.

I have tried the snippets provided here:

http://matplotlib.org/examples/event_handling/pick_event_demo.html
Possible to make labels appear when hovering over a point in matplotlib?
Is there a matplotlib equivalent of MATLAB's datacursormode?
Matplotlib basemap: Popup box

But none of them work. The plot shows but is not interactive. I tried with and without the magic %matplotlib inline with no effect. I of course also modified the print statement when it was without parenthesis.
Is there a specific command or backend to use in order to have the interaction working in Jupyter?

EDIT: the example working with mpld3 "works" but i would rather stick to the basic matplotlib.

like image 310
Radar Avatar asked Nov 25 '25 14:11

Radar


1 Answers

I think you want %matplotlib notebook. This will integrate interactive plots in the notebook.

like image 107
Stop harming Monica Avatar answered Nov 28 '25 03:11

Stop harming Monica



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!