8

I would like to have zooming and panning options for plots generated in matplotlib on jupyter notebook. I tried installing mpld3 but importing the package doesn't generate my plots at all. Is it an issue of the version of Anaconda I'm using (Anaconda2)? What should I do to fix it? Any help is appreciated, Thank You

eyllanesc
  • 235,170
  • 19
  • 170
  • 241
Tanmay Bhore
  • 89
  • 2
  • 9
  • Try run magic command `%matplotlib notebook` prior to the plot. – swatchai Dec 09 '18 at 04:57
  • 2
    For zooming and panning you need an interactive backend. Often the default settings of IPython/jupyter notebook are to show a png image of the plot; pngs are not interactive. You may use e.g. `%matplotlib qt`, `%matplotlib notebook`, `%matplotlib ipympl`. – ImportanceOfBeingErnest Dec 09 '18 at 11:20

2 Answers2

0

for me, the following worked:

  1. install ipympl, the backend for matplotlib to draw, is interactive: pip install ipympl or conda install ipympl (ipympl install in jupyter-notebook (python3))
  2. install ipywidgets, the jupyter stuff ipympl needs to draw: pip install ipywidgets or conda install ipywidgets (IPython Notebook ipywidgets does not show)
  3. use the matplotlib magic: %matplotlib ipympl

related other questions:

hintze
  • 544
  • 2
  • 13
0

For me ipympl didn't work, but this magic did helped:

%matplotlib notebook

enter image description here

Found at https://www.youtube.com/watch?v=meR8ehNxAK4

Mikhail M
  • 929
  • 2
  • 10
  • 23