Plotly graphs don't render on JupyterLab installed with Zero To JupyterHub (GKE)

Viewed 1148

I was trying to render Plotly graphs on JupyterLab that I installed with Zero to JupyterHub on GKE. I followed the documentation here :

https://plotly.com/python/getting-started/

But still, graphs don't render directly on JupyterLab. Is there something else that I'm missing?

Thanks for your help!

2 Answers

Found the answer, you have to actually add a few more steps to the process. Here it is in full:

  1. Install plotly pip install plotly==4.9.0
  2. Install / Upgrade Jupyterlab widget pip install jupyterlab "ipywidgets>=7.5"
  3. Install jupyterlab Extension jupyter labextension install jupyterlab-plotly@4.9.0
  4. OPTIONAL jupyter labextension install @jupyter-widgets/jupyterlab-manager plotlywidget@4.9.0
  5. OPTIONAL, Check extensions installed jupyter labextension list
  6. Refresh the page of your jupyterlab
  7. Build image by running jupyter lab build

Now you can open a notebook and run some sample plotly code:

import plotly.graph_objects as go
fig = go.Figure(data=go.Bar(y=[2, 3, 1]))
fig.show()

You should see the graph appearing ;)

A simpler solution that seems to work is:

import plotly.graph_objects as go

fig = go.Figure(data=go.Bar(y=[2, 3, 1]))

fig.show(renderer="iframe")

It seems to work fine as well

Related