JupyterLab: "Javscript Error: Cannot set properties of null"

I’m noticing a funny interaction between Plotly and a version of Jupyter Lab. Instead of giving me a 3D surface plot , I get a blank 3D block and an error message that reads: “Javascript Error: Cannot set properties of null (setting '0')”.

Code that runs fine in Jupyter Notebook, such as the official 3d surface plot documentation, or the following small example, produce the error in Jupyter lab:

import torch 
import plotly.graph_objects as go

zz = torch.rand(33,33)
x = torch.linspace(0, 1, steps=zz.shape[-2]).numpy()
y = torch.linspace(0, 1, steps=zz.shape[-1]).numpy()

fig = go.Figure(data=[go.Surface(z=zz.cpu().numpy(), x=x, y=y)])
fig.show()

So, the expected result is what I see when I run in jupyter notebook (not lab) or raw python script:

But instead what I see in JupyterLab is this:

Since this code works fine in regular python or Jupyter notebook, I’m pursuing this problem on both Plotly and Jupyter forums to see if anyone can suggest a fix. So far I’ve only found one instance of a similar problem reported on the web but there were no replies to the question.

Any idea? Thanks.

To be clear: I don’t believe this is a plotly bug or a jupyter bug, just some weird problem with one particular server installation. Happens for multiple versions of Plotly and multiple versions of Jupyter, and on multiple browsers.

Update: This seems to affect only Surface plots! I can do 3D Scatter plots just fine! ? (but I want a surface plot)

Bumping. I just started seeing this in Jupyter Lab. I’m using Jupyter Lab version 4.0.0 and Plotly version 5.17.0. I looked around online and couldn’t find many other references to the issue. @mcskwayrd did you ever find a solution or work-around?

Hey @dangc,

Apparently people have been facing various issues with Dash on Jupyter Lab v4…

1 Like