I am working on Jupyterlab on a docker container, on an EC2 machine on AWS, versions:
IPython : 7.30.1 ipykernel : 6.6.0 ipywidgets : 7.6.3 jupyter_client : 7.1.0 jupyter_core : 4.9.1 jupyter_server : 1.13.1 jupyterlab : 3.2.5 nbclient : 0.5.9 nbconvert : 6.4.4 nbformat : 5.1.3 notebook : 6.4.6 qtconsole : not installed traitlets : 5.1.1
When rendering plotly figures, I get an empty white frame
import plotly.express as px df = px.data.iris() fig = px.scatter(df, x="sepal_width", y="sepal_length", color="species") fig.show()
I am seeing these error in the console, but I do not understant what the issue is from them:
There are some pointers on the pypi page and their troubleshooting page.
Otherwise, tough to say: there are many
plotly packages, and I hadn’t seen
express before. In the bad old days of
jupyter labextension install ... && jupyter lab build,
plotly was frequently an issue, due to its size: hopefully you’ve just got their prebuilt static assets: if
jupyter labextension list shows… a lot of things, you might need to do some cleanup with a fresh environment.
In case it helps test what combinations may work, your code works when pasted into a cell in the notebook that launches from here where I was using plotly express for 3D. You can survey what versions that shows.
I tried many different solutions suggested in the plotly documentation, most of them did not change the behavior, but one of them did, which raises more questions than answers. The workaround was trying different renderers for plotly to see if any of them will show the graph (by specifying fig.show(renderer=“notebook”) for example). The following renderers all produce the blank output:
‘notebook’, ‘notebook_connected’, ‘kaggle’, ‘azure’, ‘cocalc’, ‘json’, ‘png’, ‘jpeg’, ‘jpg’, ‘svg’, ‘browser’, ‘iframe’, ‘iframe_connected’
however, when specifying fig.show(renderer=“colab”), the figure displays fine, but I would prefer to find a way to get the other common renderers working again. Any ideas?
I had similar issue to OP (.ipynb file in jupyter lab on docker image). explicitly passing in the renderer solved it with three separate options all working.
import plotly.express as px
df = px.data.iris()
fig = px.scatter(df, x='sepal_width', y='sepal_length', color="species")
# all three of these worked