Plotly.py: No barcharts in Jupyter Lab

Created on 5 Oct 2017  路  5Comments  路  Source: plotly/plotly.py

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')

Most helpful comment

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:

image

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

image

and 3-d plots:

image

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!

All 5 comments

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:

2017-11-04_171658

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:

2017-11-05_142016

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().

Closing the loop here. I was having issues with jupyter lab in general related to this yesterday.

I had been using the --dev-mode option as mentioned, but just went through and did jupyter lab build as described here and all is well for me now.

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:

image

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

image

and 3-d plots:

image

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!

Was this page helpful?
0 / 5 - 0 ratings