lets-plot icon indicating copy to clipboard operation
lets-plot copied to clipboard

Add png and jpeg support to ggsave

Open schakalakka opened this issue 3 years ago • 4 comments

It seems that ggsave in lets-plot-kotlin supports more file formats like png and jpeg. Is there a specific problem with the python version for not supporting these formats?

schakalakka avatar Sep 14 '22 13:09 schakalakka

Yes, it turned out to be not a trivial task in Python so we put it away for a while.

alshan avatar Sep 14 '22 19:09 alshan

I understand. A workaround I am using right now is the cairosvg package.

from cairosvg import svg2png
...
p = ggplot(..) + ...
ggsave(p, filename='mysvg.svg', ...)
svg2png(url='mysvg.svg', write_to='mypng.png')

For anyone who is interested in saving the plots as png files.

schakalakka avatar Sep 14 '22 19:09 schakalakka

Looks good! One possible issue might be their LGPLv3 license. Its copyleft-type license and we possibly are not allowed to bundle CairoSVG with Lets-Plot or even just hardcode a dependency on CairoSVG. But this need to be checked.

alshan avatar Sep 14 '22 22:09 alshan

I am no legal expert but it seems that it does not affect your license if you use the library as it is.

schakalakka avatar Sep 15 '22 05:09 schakalakka

I've ask our legal dept for clarification. I hope you are right.

alshan avatar Oct 03 '22 21:10 alshan

They said that we can use CairoSVG but we shouldn't install it by default and instead should prompt user to install CairoSVG himself when required.

alshan avatar Nov 04 '22 23:11 alshan

I just tested CairoSVG and found that almost everything works fine except a style="font:..." we use for some parts of a plot. It will take some time to switch to font-family, font-size and other properties that are compatible with CairoSVG.

IKupriyanov-HORIS avatar Jan 18 '23 16:01 IKupriyanov-HORIS

Done (PNG only) in v3.1.0.

@schakalakka , thanks for tipoff )

alshan avatar Mar 10 '23 19:03 alshan