ggplot_tricks icon indicating copy to clipboard operation
ggplot_tricks copied to clipboard

auto contrast for alpha values

Open padpadpadpad opened this issue 9 months ago • 2 comments

Hi @teunbrand,

I love the autocontrast function, but was wondering how I might be able to get it to work when using the alpha (transparency) argument within geom_tile(). Currently it just turns all tiles black or white depending on the base colour, whereas it would be awesome if it changed based on the colour after the transparency has occurred.

Cheers Dan

padpadpadpad avatar Apr 07 '25 12:04 padpadpadpad

Thanks for the suggestion Dan! How should it behave in the extreme case of completely transparent colours? I think that would depend on the background, no?

teunbrand avatar Apr 07 '25 12:04 teunbrand

Yes it would. I suppose it might be a case of converting the alpha + colour values to actual hex codes first and then passing them onto ggplot2 and the autocontrast function.

padpadpadpad avatar Apr 07 '25 13:04 padpadpadpad