plotly.plotly has an image generation API that allows you to save images in different file formats.
import plotly.plotly as py
py.image.save_as(fig)
plotly.offline allows you to export images too...
import plotly.offline as py
py.plot(fig, image=file_type, image_filename=file_name)
However, this results in a HTML file that's opened in a new tab of the browser. The image is saved to the 'Downloads' folder, and it's not possible to specify the path at which the image should be saved.
This limits the use of plotly for users that do not have access to the server, as there is no way to programatically generate lots of images. Employees at most companies would not be able to use online mode for saving images, because of Export Control/IP issues associated with transmitting data outside of the company.
Is there a reason that the save_as() methods can't be made available for plotly.offline?
I think is related to this question in the community forum https://community.plot.ly/t/save-image-as-png-or-svg/7027
There's a ton of existing issues around this. Please take a look at those, as the response is always the same: closing with the statement that "this is not on the feature roadmap."
I would suggest filling out a feature request to get the community voice behind things. Also, I'm making an attempt to rally suggestions on how this could be done at #880 so that the community could take a shot. In other words, maybe the plotly team won't do it, but if they point us in the right direction, some of us could contribute this feature.
Feature request submitted!
Closing this as the issue is duplicated at #880
Update: Offline programmatic static image export support has been released in 3.2.0: See https://medium.com/@plotlygraphs/plotly-py-end-of-summer-updates-5422c98b9058