3

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.

1 Answer 1

11

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

Sign up to request clarification or add additional context in comments.

2 Comments

Yep that was the solution. However do you know how to remove the pan/zoom tool at the bottom left of the plot and the "figure" header at the top of the %matplotlib notebook display? They are distracting and inesthetic
I don't know. I remember (vaguely) trying to remove the toolbar with this backend and failing. This is something that deserves its own question in SO if there isn't one yet.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.