1

I generated some interactive graphs using Plotly with Python in a Jupyter Notebook, but I couldn't seem to export them as HTML files. The export menu that was supposed to show up at the bottom-right corner, according to some thread online, just wasn't there.

The workflow of using Plotly with Python puzzles me. Can I write code to save interactive graphs to local drive automatically? Or do I have to use chart_studio? If so, how?

import plotly.graph_objs as go

data = list()
COLORS = ["aqua","sienna","coral","darkgreen","darksalmon",
          "darkslateblue","greenyellow","maroon","violet"]

for county, col in zip(COUNTIES,COLORS):
    trace = go.Scatter(x = DF.columns,
                       y = DF.loc[county,:],
                       name = county,
                       line = dict(color = col),
                       opacity = 0.8)
    data.append(trace)

fig = go.Figure(data = data,
                layout = dict(title = "County-level (Normalized) Daily New Cases"))
fig.show()

snapshot]

1 Answer 1

5

This is available in documentation see here

fig.write_html("path/to/file.html")

If you need to get a smaller footprint file and your file is going to be opened from a pc connected to internet you can use

fig.write_html("path/to/file.html", include_plotlyjs="cdn")
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.