I got a super graph that I would like to export as an html file to be showed on an website but I don't know how to figure that. Have you got an idea ?
Asked
Active
Viewed 3,196 times
1 Answers
1
You can use mpld3
. This is a great tutorial. The mpld3
library's main functionality is to take an existing matplotlib
visualization and transform it into some HTML
code that you can embed on your website.
Use fig_to_html
file, which accepts a matplotlib
figure object as its sole argument and returns HTML.
To use the fig_to_html method , simply add the following code to the end of our Python script:
html_str = mpld3.fig_to_html(fig)
Html_file= open("index.html","w")
Html_file.write(html_str)
Html_file.close()

sam patel
- 23
- 4
-
Thank for the help ! I fiound an antoher way to save it if someone read this post : import plotly.io as pio pio.write_html(fig, file="Forecast_HTML.html", auto_open=True) and it saved it easily ! – NathanRDN Dec 24 '20 at 16:06