SciProgCentre / plotly.kt

An interactive Kotlin wrapper for plotly visualization tools
https://sciprogcentre.github.io/plotly.kt/
Apache License 2.0
147 stars 21 forks source link

Export to static image without orca #86

Closed zxcqirara closed 1 year ago

zxcqirara commented 2 years ago

How can I export plot to local PNG or JPG without orca?

altavir commented 2 years ago

Since Plotly is a web-based library, it is not possible to directly export image from JVM. It is possible to do from the plot itself: image You can change the format of exported image like it is done here.

It is also possible to export image via python package provided by plotly, but it is not that relyable: https://github.com/mipt-npm/plotly.kt/blob/master/examples/src/main/kotlin/svgSaveViaOrca.kt

zxcqirara commented 2 years ago

Since Plotly is a web-based library, it is not possible to directly export image from JVM. It is possible to do from the plot itself: image You can change the format of exported image like it is done here.

It is also possible to export image via python package provided by plotly, but it is not that relyable: https://github.com/mipt-npm/plotly.kt/blob/master/examples/src/main/kotlin/svgSaveViaOrca.kt

I need to export it to PNG from code, not manually

altavir commented 2 years ago

Sadly, it is possible only via Orca. Plotly recommends to use the new tool Kaleido (https://plotly.com/python/static-image-export/), but last time we tried, it was bugged and was almost impossible to use outside python. As far as I can understan, it just uses chromium embedded to render the plot and save the picture. So this option does not work that well. Sadly, it is a limitation of the underlying library.