How do I save the following, graph created after graph.show()
, as JPG, PNG, or PDF to a specific directory?
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")
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:
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.