Reputation: 9138
I am running JupyterLab 3.0.6 and Plotly 4.14.1. It seems all the plotly dash plugins are outdated? Is there any extension that works with JupyterLab 3 yet?
E.g.
import plotly.express as px
px.line([1,2,3,2])
Only shows an empty output.
Upvotes: 6
Views: 5550
Reputation: 1
As described by @piedpiper in https://stackoverflow.com/a/77320500/23203605, pio.renderers.default is the key in my JupyterLab 3 setup.
This fixed my problem:
import plotly.io as pio
pio.renderers.default = 'iframe'
Upvotes: 0
Reputation: 398
Complete answer that worked for me on JupyterLab 4.0.5
pip install plotly
pip install ipywidgets
import plotly.express as px
import plotly.io as pio
# At least one of these should work
pio.renderers.default = 'iframe' # or 'notebook' or 'colab' or 'jupyterlab'
fig = px.scatter(df, x, y)
Then I could actually see the plot!
Upvotes: 0
Reputation: 252
As mentioned in the comment How to show Plotly figures in JupyterLab 3+? with JupyterLab 3.x and Plotly 5.x labextension installation of plotly is outdated.
Installation: https://plotly.com/python/getting-started/#installation
Upvotes: 0
Reputation: 258
To install Plotly on JupyterLab 3 on ubuntu is necessary to install nodejs, npm and jupyterlab plotly extension
The instructions on the plotly website didn't worked for me. The graph was being rendered as a white square. I discovered that jupyterlab plotly extension is working, but on Ubuntu it depends on nodejs and npm.
apt install nodejs npm
jupyter labextension install jupyterlab-plotly
Reestart the jupyter and it should be working like the example bellow.
Upvotes: -1
Reputation: 9138
It is working now.
conda install -c plotly plotly=4.14.3
conda install "notebook>=5.3" "ipywidgets>=7.5"
jupyter labextension install [email protected]
# OPTIONAL: Jupyter widgets extension
jupyter labextension install @jupyter-widgets/jupyterlab-manager [email protected]
https://plotly.com/python/getting-started/
Upvotes: 2
Reputation: 538
This question has already been answered by one of the plotly developers.
Plotly express is not rendered in jupyter lab
Edit: That link is old sorry. After some more research it appears jupyter lab 3 is not currently compatible with plotly. They are currently working on it.
https://community.plotly.com/t/jupyterlab-plotly-not-compatible-with-jupyterlab-3-0/48777
Upvotes: 1