5

I just tried to use plotly offline in a jupyter notebook (using jupyter lab). The docs gives this example:

import plotly
import plotly.graph_objs as go

plotly.offline.init_notebook_mode(connected=True)

plotly.offline.iplot({
    "data": [go.Scatter(x=[1, 2, 3, 4], y=[4, 3, 2, 1])],
    "layout": go.Layout(title="hello world")
})

I tried it and there is no chart displayed, either in Edge or Firefox.
An output cell is made in the notebook, but there is no chart.

It works if I use plotly.offline.plot rather than iplot. It works if I use the traditional jupyter notebook rather than jupyter lab.

Any ideas why it does not display?

It's plotly version 2.7.0.

blokeley
  • 6,726
  • 9
  • 53
  • 75

2 Answers2

4

Have you installed Plotly JupyterLab extension? It will not work inline without it. You can get it here: https://github.com/jupyterlab/jupyter-renderers/tree/master/packages/plotly-extension

or just install via terminal: jupyter labextension install @jupyterlab/plotly-extension

dejanmarich
  • 1,235
  • 10
  • 26
  • Installed Node.js 10.16.0 using the windows installer, but when I executed the terminal command, I get the error "ValueError: Please install nodejs 5+ and npm before continuing installation...". Not sure how to make jupyter lab recognize/find what it needs. – Michael Szczepaniak Jun 11 '19 at 03:31
4

I don't have enough points to add the comment: The @jupyterlab/plotly-extension has been deprecated in favor of the plotly supported render extension, which is at: https://www.npmjs.com/package/jupyterlab-plotly.

Install via:

jupyter labextension install jupyterlab-plotly
סטנלי גרונן
  • 2,917
  • 23
  • 46
  • 68
JimC
  • 69
  • 1
  • 7