I have a Jupyter notebook (python) where I used plotly express to plot in the notebook for analysis purposes. I want to share this notebook with non-coders, and have the interactive visuals be available still - but it does not seem to work.
I tried following recommendations made here but even after saving widgets state and using nbconvert
, when I open the new HTML file, the visuals are not available.
A sample line of plotting can be seen below:
import plotly_express as px
fig = px.scatter(
df,
x='size',
y='size_y',
color='clients',
hover_data=['id'],
marginal_y="histogram",
marginal_x="histogram"
)
fig.show()
After running plotly.offline.init_notebook_mode()
in a cell,
you can export the notebook with full interactivity via the file menu:
File --> Export Notebook as... --> Export Notebook to HTML
.
I was having similar issues but with JupyterLab. Followed the instructions here: https://plot.ly/python/renderers/ .
import plotly.io as pio
pio.renderers.keys()
I had to add the following snippet to my script:
import plotly.io as pio
pio.renderers.default = 'jupyterlab'
Exporting as HTML after that worked for me. You can read "Overriding the default renderer".
I suppose you would need
pio.renderers.default = 'notebook'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With