[英]How do I save plotly graph as jpg
How do I save the following, graph created after graph.show()
, as JPG, PNG, or PDF to a specific directory?如何将在graph.show()
之后创建的以下图形保存为 JPG、PNG 或 PDF 到特定目录?
The code :代码:
import plotly.graph_objects as go
graph = go.Figure(data=[go.Candlestick(x=df['Date'],
open=df['AAPL.Open'], high=df['AAPL.High'],
low=df['AAPL.Low'], close=df['AAPL.Close'])
])
graph.show()
A simple google search showed me一个简单的谷歌搜索告诉我
graph.write_image("name_of_file.jpeg")
https://plotly.com/python/static-image-export/ https://plotly.com/python/static-image-export/
This will work:这将起作用:
graph.write_image("name_of_file.jpeg")
But you'll have to install kaleido.但是你必须安装万花筒。 From the plotly docs you can see that:从plotly 文档中,您可以看到:
Static image generation requires either Kaleido (recommended, supported as of plotly 4.9) or orca (legacy as of plotly 4.9). The kaleido package can be installed using pip.
$ pip install -U kaleido
or conda.或康达。
$ conda install -c plotly python-kaleido
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.