These resources show how to take data from a single Pandas DataFrame and plot different columns subplots on a Plotly graph. I\'m interested in creating figures from separate
Here's a short function in a working example to save a list of figures all to a single HTML file.
def figures_to_html(figs, filename="dashboard.html"):
dashboard = open(filename, 'w')
dashboard.write("" + "\n")
for fig in figs:
inner_html = fig.to_html().split('')[1].split('')[0]
dashboard.write(inner_html)
dashboard.write("" + "\n")
# Example figures
import plotly.express as px
gapminder = px.data.gapminder().query("country=='Canada'")
fig1 = px.line(gapminder, x="year", y="lifeExp", title='Life expectancy in Canada')
gapminder = px.data.gapminder().query("continent=='Oceania'")
fig2 = px.line(gapminder, x="year", y="lifeExp", color='country')
gapminder = px.data.gapminder().query("continent != 'Asia'")
fig3 = px.line(gapminder, x="year", y="lifeExp", color="continent",
line_group="country", hover_name="country")
figures_to_html([fig1, fig2, fig3])