2

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.

Community
  • 1
  • 1
Radar
  • 935
  • 3
  • 9
  • 23

1 Answers1

11

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

Stop harming Monica
  • 12,141
  • 1
  • 36
  • 56
  • 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 – Radar Jan 21 '17 at 15:08
  • 1
    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. – Stop harming Monica Jan 21 '17 at 16:52