plot.ly offline mode in jupyter lab not displaying plots plot.ly offline mode in jupyter lab not displaying plots python python

plot.ly offline mode in jupyter lab not displaying plots


A couple things might be happening. For some reason is your Notebook "Not Trusted?" This will stop the Plotly javascript from rendering anything below.

Another possibility is that you don't have the Plotly extension installed for Jupyter Lab. In Lab, as compared to Notebooks, there are a lot more restrictions on what javascript can execute, so packages need to have extensions installed in order to display anything beneath the cell.

Look for the plotly-extension withjupyter labextension list

and install it if missing with: jupyter labextension install jupyterlab-plotly


Try changing the renderer:

import plotly.io as piopio.renderers.default = 'iframe' # or 'notebook' or 'colab' or 'jupyterlab'

You can loop through the list like this to see what fits you

import pandas as pdimport plotly.express as pximport plotly.io as piofor text in pio.renderers:    print(text)    pio.renderers.default = text    df = px.data.iris()    fig = px.scatter(df, x="sepal_width", y="sepal_length", color="species")    fig.show()


Plotly-extension has been deprecated, use another:

jupyter labextension install jupyterlab-plotly

it worked for me and it has no compatibility issues with the latest versions of plotly (currently 4.9.0) / jupyterlab

source: https://plotly.com/python/getting-started/ , https://www.npmjs.com/package/@jupyterlab/plotly-extension