Skip to content

Expose js an api function for saving figures as png/pdf/jpeg/eps/etc with config #89

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
sglyon opened this issue Dec 8, 2015 · 8 comments

Comments

@sglyon
Copy link

sglyon commented Dec 8, 2015

I'm sorry if this is already in another issue somewhere. I looked around a bit, but couldn't find it

It would be awesome if the Snapshot functions were exposed at a higher level - perhaps through something that would work like this:

Plotly.save(gd, {format: 'pdf', width: '800', height: '450', dpi: '400'})

which would then trigger the download of the requested file (similar to how the snapshot button triggers a png download right now)

Being able to easily save to to a vector image backend like pdf or eps with specified sizes and dpi would be amazing -- then I could publish my plotly figures in latex based research articles.

@etpinard
Copy link
Contributor

etpinard commented Dec 9, 2015

Marked as duplicate of #83

All image formats listed other than png and svg required a convert step outside the js realm. That is, this will never be part of plotly.js.

Luckily, the plotly cloud handle all those image formats for you. For example, in node.js.

@mdtusz
Copy link
Contributor

mdtusz commented Dec 9, 2015

@spencerlyon2 another option if you would like to handle pdf's in the browser could be jsPDF, although I haven't used it, and it may not play nicely with plotly plots - you would need to convert from canvas -> png -> pdf using jsPDF.

@sglyon
Copy link
Author

sglyon commented Dec 9, 2015

OK no problem, I can handle it outside of the plotly/javascript realm.

Is there as suggested method for causing the download of an SVG?

@etpinard
Copy link
Contributor

etpinard commented Dec 9, 2015

@spencerlyon2 this is what #83 will attempt to solve.

@etpinard
Copy link
Contributor

closed in favout of #83

@etpinard
Copy link
Contributor

etpinard commented May 16, 2016

svg, png, jpg and webp to-image exports are now available natively via Plotly.toImage as of #446.

For vector-quality pdf or eps figures, I would recommend exporting your graph to an svg and using a conversion utility such as imageMagick to convert the svg to a pdf or eps.

@etpinard
Copy link
Contributor

@timelyportfolio oops. Fixed above. Thanks!

@ghost
Copy link

ghost commented Jul 22, 2017

Hi, I have export my image as svg and do convert -density 300 <image>.svg <image>.png, but the quality doesn't seem to improve. What's wrong? Since we can't set dpi in plot.ly (I'm using python), the only way would be scaling width and height and the marker size, which is inconvenient.

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

3 participants