I recently discovered plotly and find it really good for graphing, now I have a problem which I want to save multiple plot into a single html, how to do it please?
*I wa
In the Plotly API there is a function to_html
which returns HTML of the figure. Moreover, you can set option param full_html=False
which will give you just DIV containing figure.
You can just write multiple figures to one HTML by appending DIVs containing figures:
with open('p_graph.html', 'a') as f:
f.write(fig1.to_html(full_html=False, include_plotlyjs='cdn'))
f.write(fig2.to_html(full_html=False, include_plotlyjs='cdn'))
f.write(fig3.to_html(full_html=False, include_plotlyjs='cdn'))
https://plot.ly/python-api-reference/generated/plotly.io.to_html.html
You can also use Beautiful Soup to do DOM manipulation and insert DIV exactly where you need it in the HTML.
https://beautiful-soup-4.readthedocs.io/en/latest/#append