I would need to share the content of some jupyter notebooks in a HTML format. Normal figures displayed by the iplot command work fine, but the Figurewidgets are not supported in the export and do not show up.
As an example, the following code works well in jupyterlab but i cannot export it to html (using the export menu):
import pandas as pd
import plotly.graph_objs as go
import ipywidgets as widgets
x = np.linspace(0,2*np.pi,10)
y = np.sin(x)
trace = go.Scatter(x=x,y=y)
data = [trace]
fig = go.FigureWidget(dict(data=data))
widgets.HBox([fig,fig])
Run the notebook using the classic JupyterNotebook (not JupyterLab)
Save notebook using the “Widgets -> Save Notebook Widgets State” menu item
Use nbconvert on the command line to convert the notebook to HTML (See https://github.com/jupyter/nbconvert). I have nbconvert version 5.4.0 installed.
$ jupyter nbconvert --to html mynotebook.ipynb
As far as I know, it’s not yet possible to save the notebook widget state to the notebook using JupyterLab. And the notebooks own “File -> Download As -> HTML” doesn’t embed the widget info inte exported HTML.
Also note that unlike the iplot approach, the widget JavaScript libraries are pulled form a CDN not embedded in the notebook. So the produced HTML files will require an internet connection.
Same as @Yannly, tried this exact same solution, and the exported HTML notebook had no figures showing. @jmmease can you please advise if you found an alternative solution?
Steps 1. and 2. can now be done within the recent JupyterLab versions by enabling the setting “Settings” -> “Save Widget State Automatically” and saving the notebook.
You still have to run nbconvert from the command line as in Step 3, since “Export Notebook to HTML” still doesn’t work with Plotly.