ipympl icon indicating copy to clipboard operation
ipympl copied to clipboard

matplotlib widget occasionally fails to render.

Open pulkin opened this issue 5 years ago • 6 comments

Bug report

Bug summary

Matplotlib widget occasionally fails to render.

Code for reproduction

%matplotlib widget
from matplotlib import pyplot
fig, axes = pyplot.subplots(1, 2, figsize=(8, 4))
pyplot.show()
raise

Actual outcome

Screenshot

Expected outcome

Two empty subplots.

Matplotlib version

  • Operating system: some sort of linux running docker running jupyterlab
  • Matplotlib version: 3.2.1
  • Matplotlib backend (print(matplotlib.get_backend())): module://ipympl.backend_nbagg
  • Python version: 3.8.2
  • Jupyter version (if applicable): jupyterlab 2.0.2
  • Other libraries:

pulkin avatar May 19 '20 13:05 pulkin

If in the next cell you do fig.canvas and let jupyter repr that do you get a live figure? My suspicion is that some part of the ipywidgets setup that links the JS to the kernel is set up as part of the code that is run by jupyter when a cell is done successfully and not done as part of the code that runs when a cell fails.

tacaswell avatar May 19 '20 13:05 tacaswell

If in the next cell you do fig.canvas and let jupyter repr that do you get a live figure?

fig.canvas in the subsequent cell renders exactly as the above.

pulkin avatar May 19 '20 13:05 pulkin

I think this mostly on the widget side of the house, moved to ipympl.

tacaswell avatar May 22 '20 00:05 tacaswell

Do you get an error in the JavaScript console? https://webmasters.stackexchange.com/questions/8525/how-do-i-open-the-javascript-console-in-different-browsers

martinRenou avatar May 25 '20 07:05 martinRenou

There is nothing I could associate with the issue. Also, nothing is output when I try to reproduce the issue by pressing ctrl-enter.

pulkin avatar May 25 '20 09:05 pulkin

Another connected outcome of this issue: When restarting and running a longer notebook from top to bottom all figures do not show up if the execution ends with an exception:

image

This means you have to manually executes cells step by step so that you never run a cell together with another cell that raises an exception later.

This happens reproducibly here with the current ipympl 0.5.6 but also with earlier versions.

asteppke avatar Jun 05 '20 12:06 asteppke