Reputation: 33
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()
Upvotes: 3
Views: 4341
Reputation: 61204
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
Upvotes: 2
Reputation: 81
A simple google search showed me
graph.write_image("name_of_file.jpeg")
https://plotly.com/python/static-image-export/
Upvotes: 2