%matplotlib inline versus %matplotlib notebook display problems in pythonAnywhere jupyter

user3556757 picture user3556757 · Jan 2, 2018 · Viewed 10.2k times · Source

This is not a duplicate as suggested. I am not trying to switch backends. I am just trying to use the %matplotlib notebook formulation. Moreover, the solutions suggested in that other question (place the%matplotlib notebook before the the from matplotlib import pylplot as plt OR trying call the magic command twice in a row) do not work for me. The behavior (blank notebook charts) remains.


place the%matplotlib notebook before the the from matplotlib import pylplot as plt OR trying call the magic command twice in a row

When I use %matplotlib inline my charts always show, but they're generally on the small side, and have no ability to zoom/pan.

When I use %matplotlib notebook I get zoomable, pannable charts, but I sometimes encounter problems where the charts display as blank.

enter image description here

Background:

PythonAnywhere notebook 3.6 Python. Using update Google Chrome from Windows 7.

If I reopen my existing notebook, even restart the kernel and re-run all the cells, all my .plot() appear blank. But if I contemporaneously start a brand new 3.6 notebook, %matplotlib notebook plots work fine. Killing all the jupyter-related processes doesn't help either.

This does not always occur. But if one chart appears blank, they all appear blank.

I would like to use the notebook magic, but this problem is pretty profound.

enter image description here

Answer

Barbera picture Barbera · Feb 24, 2020

I have found some stability on using %matplotlib notebook, after including plt.close(), before all my plots.

A pretty dirty solution, I know, but it's working. Here Windows 10, Python 3.6.2 and Jupyter 6.03 (updated Jupyter haven't solved the issue). Hope this helps.