Skip to content

No barcharts in Jupyter Lab #849

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
hiramf opened this issue Oct 5, 2017 · 5 comments
Closed

No barcharts in Jupyter Lab #849

hiramf opened this issue Oct 5, 2017 · 5 comments

Comments

@hiramf
Copy link

hiramf commented Oct 5, 2017

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')
@dhirschfeld
Copy link

That's sn issue with the JupyterLab renderer but is fixed in the latest version 0.10.0
jupyterlab/jupyter-renderers#21

You should just need to update your labextension.

@jwhendy
Copy link
Contributor

jwhendy commented Nov 4, 2017

@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?

@jwhendy
Copy link
Contributor

jwhendy commented Nov 5, 2017

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

@jwhendy
Copy link
Contributor

jwhendy commented Nov 5, 2017

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.

@fperez
Copy link

fperez commented Mar 15, 2018

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!

@fperez fperez closed this as completed Mar 15, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants