https://plotly.com/python/static-image-export/
pip install kaleido
from kaleido.scopes.plotly import PlotlyScope
import plotly.graph_objects as go
import os
scope = PlotlyScope()
fig = go.Figure(data=[go.Scatter(y=[1, 3, 2])])
if not os.path.exists("images"):
os.mkdir("images")
with open("./images/figure.png", "wb") as f: # 在本地目录下面就会生成文件
f.write(scope.transform(fig, format="png"))