transparent background option for ggsave and `to_*()` methods
From what I understand of the #121 transparent rendering was the default. But currently, when I needed to save a plot with a transparent background I could not find the option the save with the transparent background. I was expecting something like transparent = True or bg = "transparent".
I did some workaround with...
+ theme(
panel_background=element_blank(),
plot_background=element_blank(),
legend_background=element_blank(),
)
but this feels very tedious and even so I could not remove legend elements' background as the following.
Agreed, the legend icons' background should be transparent. However, saving a plot image with transparency doesn't seem to be a common case. So there is no dedicated boolean argument for that. I'm wondering, why do you need the transparency?
Agreed, the legend icons' background should be transparent.
Definitely, thanks!
I'm wondering, why do you need the transparency?
Well for one, on backgrounds with any other color than white (e.g., presentation). Sometimes people have to do use black, gray background or some specific background color on their instutions or companies. Or when you overlay/overlap multiple elements on top of each other, with non-transparent background you have to deal with the arrangments (back, front) etc., even so you might not get the look or arrangement you want, as white background covers the image or element behind.
I've removed the background from legend icons (commit).
For now, if you only need to match the background color with the background color on the slides, you can do:
bg = element_rect(fill="#d0d0d0")
... theme(
plot_background=bg,
legend_background=bg)
BTW, in either case, configuring plot_background is unnecessary:
+ theme(
panel_background=element_blank(),
legend_background=element_blank(),
)
will lead to the same result with the default (and most other) themes and to a better result when using theme_grey().
Sorry for confusion,
BTW, in either case, configuring
plot_backgroundis unnecessary:
I meant panel_background :)
Thanks for the tip.
I would still really like to see the ability to save with fully transparent backgrounds.
My company for example uses slides with a dark gradient background. Creating charts in white with transparent background looks really good and it is part of our corporate design.
It is an edge case but nice nonetheless.
Hi @concimuscb
+ theme(
plot_background=element_blank(),
legend_background=element_blank(),
)
will produce transparent plot in the coming soon release 4.5. If urgent however, you can already use today's RC version : https://pypi.org/project/lets-plot/4.5.0rc2/
Amazing! Many thanks for the work and the great library :)
Released : v4.5.0