5

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

4
  • This sometimes occurs due to wrong order of commands You can refer to this question stackoverflow.com/questions/43545050/… Commented Jan 2, 2018 at 9:45
  • Possible duplicate of Using %matplotlib notebook after %matplotlib inline in Jupyter Notebook doesn't work Commented Jan 2, 2018 at 21:00
  • @VrushM Yeah thanks for that pointer. I tried all those variations, but still getting the same behavior. Commented Jan 4, 2018 at 11:13
  • 2
    It's hard to say what's happening if this only occurs sometimes. What would be needed is a minimal reproducible example of the issue. I guess that would require you to do more testing with reproducible data leading to a clear problem description, like "if I perform <step1>, <step2>, I get a blank plot, but if I perform <step1>, <step3>, the plot is shown correctly. Commented Jan 8, 2018 at 14:04

2 Answers 2

1

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.

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

Comments

0

%matplotlib qt will do your job.

Comments

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.