Plotly offline mode doesn't work in Jupyter Lab

So this is a rather novel issue because my plots are well rendered in Jupyter NOTEBOOK in offline mode, but I am unable to see them in Jupyter LAB.

Sample code :

from plotly.offline import plot, iplot, init_notebook_mode
import plotly.graph_objs as go

# Make plotly work with Jupyter notebook
init_notebook_mode()

keys=['one','two','three']
values=[1,2,3]

iplot({
    "data": [go.Bar(x=keys, y=values)],
    "layout": go.Layout(title="Sample Bar Chart")
})

In the console, a warning shows up :

JupyterLab does not execute inline JavaScript in HTML output

So if Jupyter Lab is blocking the execution of the scripts, maybe there is nothing to do, but now this issue is known.

It appears that based on this issue, The Plotly team should make a nbextension to enable the execution of the scripts.

… which is what we do in 🌟 Introducing plotly.py 3.0.0 🌟 | by Plotly | Plotly | Medium

Looks amazing. Can’t wait to use it !

Hello, I have tried the suggestions in the Medium article and on this forum and yet all I get when I run this code:

x = np.random.randn(1000)
y = np.random.randn(1000)
go.FigureWidget(data=[{‘x’ : x, ‘y’ : y, ‘type’ : ‘histogram2dcontour’}])

All I ever get is this:

FigureWidget({
‘data’: [{‘type’: ‘histogram2dcontour’,
‘uid’: '18d0b8c8-a09c-11e8-a401-46350…

What am I missing?

Thank you

also, I have used this link

Hi LabRat,

I was having the same problem and was able to fix by upgrading node and then following instructions here: https://github.com/plotly/plotly.py#jupyterlab-support-python-35.

In my case, I’m runnin on MacOS.

Hope this helps.

This is deprecated…