Skip to content

Offline way to programmatically save graph as PNG? #483

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
ghost opened this issue May 26, 2016 · 15 comments
Closed

Offline way to programmatically save graph as PNG? #483

ghost opened this issue May 26, 2016 · 15 comments
Assignees

Comments

@ghost
Copy link

ghost commented May 26, 2016

Hi, i am using plotly and like it.

I need to save graphs i created at server side as PNG images using plotly offline. Is there a way to do it?

@yankev
Copy link
Contributor

yankev commented May 30, 2016

@evrenkutar Currently the procedure in which we turn plots into static images requires communication with our servers.

@jackparmer
Copy link
Contributor

@evrenkutar @yankev If you're using Jupyter notebook, you should be able to access this toImage() routine programmatically in Python:
https://plot.ly/javascript/static-image-export/
@cldougl @yankev Can you please look at how the R client does this and add official support (and docs) for the Python client?

@hyliu1989
Copy link

hyliu1989 commented Jun 17, 2016

Chrome under Windows 10 is not working with image download (both programmatically and using mouse to click the camera thumbnail)
It was run with the commit 9e52ce4. (17 Jun 2016 16:39)
Maybe the offline js module should be synchronized with plotly.js since it has been fixed in plotly.js #604

@yankev
Copy link
Contributor

yankev commented Jun 18, 2016

@hyliu1989 Thanks for the reminder. We should be pushing a new version up on pip early next week.

@cldougl
Copy link
Member

cldougl commented Nov 1, 2016

docs of offline image exporting can be found here: https://plot.ly/python/static-image-export/#export-static-image-offline

@cldougl cldougl closed this as completed Nov 1, 2016
@NicoHood
Copy link

NicoHood commented Jul 5, 2017

@cldougl This currently opens a web browser which requests to safe the picture. If you try to export multiple PNGs this is not really a usable way. It would be nice to directly export as PNG file from python. Could you please reopen this issue?

As a workaround I found this post which converts the data into matlab. However this did not work for me with the latest plotly version.
https://stackoverflow.com/questions/40243446/how-to-save-plotly-offline-graph-in-format-png

@bluprince13
Copy link

bluprince13 commented Nov 16, 2017

@cldougl, I second @NicoHood , a programmatic way of exporting images in offline mode would be really useful - particularly for the use case of needing to export multiple images. At the moment, it's a pain!

@efayadspecific
Copy link

yes, please!! I need to programmatically create heatmaps from 2000+ Pandas data frames. having each open up in a browser is not tractable, in my opinion. thanks!

@jwhendy
Copy link
Contributor

jwhendy commented Dec 26, 2017

Since this has the most unique users of issues requesting this (there are several), would anyone here be capable to implement something if the plotly team sketched a possible method?

As all of the closed issues suggest, they probably aren't going to do this... but perhaps we could. This was my pitch in the newest incantation of this request, #880 . Perhaps if you show your support via programming chops we can get a direction to take and collaborate?

@bluprince13
Copy link

@jwhendy I hope something comes off this. I'm definitely willing to help, but I don't have any previous experience of contributing source code even in Python. JavaScript is something I've just started learning. So, may be limited in what I can do!

I do think this is a key feature that plotly is lacking, potentially even one that prevents a large population of data analysts from adopting plotly. I use plotly to probe all of my data since it's interactive, and then I have to use matplotlib to save them as plots to share with my colleagues because I'm generating hundreds of plots at a time!!

@jwhendy
Copy link
Contributor

jwhendy commented Dec 27, 2017

@bluprince13 see the most recent post at #880. I was able to make some progress on two potential methods. Feel free to try them out! I'm hoping @cldougl suggests a place one of them could fit in the library, and I'll make a pull request. Likely this will require someone more advanced than me to take a look and give input.

@jackparmer
Copy link
Contributor

Update on this issue from Plotly: #880 (comment)

@eagleEggs
Copy link

eagleEggs commented May 9, 2018

FYI this is now possible with one line after setting your data and figure:

edit [051518]: actually this doesn't work :/

data = Data([tasks, tasks2, tasks3])
fig = Figure(data=data, layout=layout)
offline.iplot(fig, filename='graph', image='png')

It saves to the /Downloads directory.

https://gist.github.com/eagleEggs/c441ffa88a90a8a360d771fae3ba2d8e

Looking for a way to change that default directory currently...

@ghost
Copy link
Author

ghost commented Jul 4, 2018

Really need this

@jonmmease
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants