Search code examples
pythonplotlyplotly-python

How to save plotly express plot into a html or static image file?


However, I feel saving the figure with plotly.express is pretty tricky.

How to save plotly.express or plotly plot into a individual html or static image file? Anyone can help?


Solution

  • Adding to @vestland 's answer about saving to HTML, another way to do it according to the documentation would be:

    import plotly.express as px
    
    # a sample scatter plot figure created
    fig = px.scatter(x=range(10), y=range(10))
    fig.write_html("path/to/file.html")
    

    You can read about it further (controlling size of the HTML file) here: Interactive HTML Export in Python