Plotting offline in Jupyter Lab produces a line chart instead of a bar chart.
Using this code in Jupyter Lab (0.27.0):
import plotly.plotly as py
import plotly.graph_objs as go
from plotly.offline import init_notebook_mode, iplot
init_notebook_mode(connected=True)
data = [go.Bar(
x=['giraffes', 'orangutans', 'monkeys'],
y=[20, 14, 23]
)]
iplot(data, filename='basic-bar')
That's sn issue with the JupyterLab renderer but is fixed in the latest version 0.10.0
https://github.com/jupyterlab/jupyter-renderers/issues/21
You should just need to update your labextension.
@dhirschfeld I'm newish to jupyterlab; can you confirm exactly what you mean by "update your labextension"?
I was not clear on whether or not it was a separate package or part of jupyterlab itself. I've used pip install --local for jupyterlab and family, so I checked like this for related packages:
find ./.local/ -iname jupyter*
I only have jupyter_core, and jupyterlab_launcher, and jupyterlab, hence my suspicion that labextension is part of jupyterlab itself. I see the binary:
### looks newer than 0.10.0 to me?
$ jupyterlab_labextension --version
0.28.12
Running @hiramf 's example above:

Am I still out of date somewhere I'm not aware of?
Returning to this. Getting to know labextension more, I think this was meant to refer to the plotly extension. I have things installed locally (still > 0.10.0):
$ jupyter labextension install --app-dir=~/.local/share/jupyter/lab @jupyterlab/plotly-extension
$ jupyterextension list --app-dir=~/.local/share/jupyter/lab
JupyterLab v0.28.12
Known labextensions:
app dir: /home/jwhendy/.local/share/jupyter/lab
@jupyterlab/plotly-extension
@jupyterlab/plotly-extension v0.11.1 enabled OK
### relevant packages:
$ pip freeze
bokeh==0.12.10
ipython==6.2.1
jupyter-client==5.1.0
jupyter-console==5.2.0
jupyter-core==4.4.0
jupyterlab==0.28.12
jupyterlab-launcher==0.5.5
I get the same blank plot above using the example right out of the offline instructions:
import plotly
from plotly.graph_objs import Scatter, Layout
plotly.offline.init_notebook_mode(connected=True)
plotly.offline.iplot({
"data": [Scatter(x=[1, 2, 3, 4], y=[4, 3, 2, 1])],
"layout": Layout(title="hello world")
})
When using the developer tools console in chromium, I see:

If it's of use at all, I've been fiddling with this, bokeh, and altair. Each seems to have it's own method to enable jupyterlab inline rendering. Both this and bokeh.io.output_notebook() are not working for me. (Same error about javascript.)
altair works with it's alt.enable_mime_rendering().
I can confirm that with current JupyterLab, and installing the extension via
jupyter labextension install @jupyterlab/plotly-extension
the following code:
import plotly.offline as py
from plotly.graph_objs import *
import plotly.graph_objs as go
py.init_notebook_mode()
trace = go.Heatmap(z=[[1, 20, 30],
[20, 1, 60],
[30, 60, 1]])
data = [trace]
py.iplot(data, filename='basic-heatmap')
renders fine:

I've been testing more complex plots, including interactive controls:

and 3-d plots:

and everything is working without a glitch.
I'm going to close this one for now as I think it's resolved, feel free to ping if it shouldn't.
cc @jegonzal who authored the code from the above screenshots. All working great on JLab!
Most helpful comment
I can confirm that with current JupyterLab, and installing the extension via
the following code:
renders fine:
I've been testing more complex plots, including interactive controls:
and 3-d plots:
and everything is working without a glitch.
I'm going to close this one for now as I think it's resolved, feel free to ping if it shouldn't.
cc @jegonzal who authored the code from the above screenshots. All working great on JLab!