Skip to content
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

How to download figures from plotly.offline.iplot after setting atttribute image='svg' #1502

Closed
sw-gong opened this issue Apr 8, 2019 · 2 comments
Labels
bug something broken
Milestone

Comments

@sw-gong
Copy link

sw-gong commented Apr 8, 2019

It is said from the help(plotly.offline.iplot):

image (default=None |'png' |'jpeg' |'svg' |'webp') -- This parameter sets
the format of the image to be downloaded, if we choose to download an
image. This parameter has a default value of None indicating that no
image should be downloaded.

My understanding is that we can download the figure as the format of the image after setting this attribute. However, how can we download it? Please see the below code. Could anyone explain what should be down next in order to download the figure?

Alternatively, I can use plotly.offline.plot which return a html link and I can download the figure after openning the link. However, the downside is that the figure won't be shown inside the jupyter notebook.

import plotly
import plotly.graph_objs as go
init_notebook_mode(True)

img_name = 'my-plot'
data = [go.Scatter(x=[1, 2, 3], y=[3, 2, 6])]
plotly.offline.iplot(data, filename=img_name, image='svg')
@jonmmease
Copy link
Contributor

Hi @sw-gong,

Looks like this was a bug introduced back in #1250. This will be fixed in version 3.8 by #1474.

That said, our recommended approach for exporting figures as static images is to use plotly.io.write_image which relies on the orca utility. See https://plot.ly/python/static-image-export/ for a full description.

@jonmmease jonmmease added the bug something broken label Apr 9, 2019
@jonmmease jonmmease added this to the v3.8.0 milestone Apr 9, 2019
@jonmmease
Copy link
Contributor

Fixed in #1474

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

No branches or pull requests

2 participants