daattali / colourpicker

🎨 A colour picker tool for Shiny and for selecting colours in plots (in R)
https://daattali.com/shiny/colourInput/
Other
217 stars 28 forks source link

Add colorblindness simulator to colourPicker #55

Open psyguy opened 1 year ago

psyguy commented 1 year ago

Hi,

Thanks for the great package – it spares me the time it takes to constantly look up R native colors and compare them with trial and error!

One thing that I see missing is a color vision deficiency simulator (like @clairemcwhite and @clauswilke's colorblindr package). Currently, I save my chosen color palette in a png file and use online tools (like this) to check whether my palette is print- and colorblind-friendly.

It would be great if you could add (three) more rows underneath the selected colors that would show how it is seen by people with protanomaly (2% of males), deuteranomaly (6% of males), tritanomaly, and desaturated (that would simulate grayscale printing) vision deficiency. Here's what I mean (poorly made in Paint 😄):

image

In case it feels like too much information overload and only one should be chosen, I believe the desaturated one (grayscale) is the most relevant since it is black-and-white print-safe and also safe for all other types of color vision deficiencies.

daattali commented 1 year ago

Thanks for the defailed description! My initial reaction was that this is out of scope for this package. I can appreciate the issue this is solving, but this tool is meant to serve one specific purpose, which is only to select colours, not to simulate them for different people. But I do see the benefit of this feature so I'll leave the issue open and will be happy to accept a PR if someone wants to tackle it.

I think rather than adding 3 rows which will be a UI nightmare, perhaps there can be a dropdown where the user can select what to display: "Real colour" or "Tritanope" or "Deuteranope" etc

clauswilke commented 1 year ago

Just FYI, if you're willing to live with a colorspace dependency, the simulation part is a single function call. You just stick your colors into the relevant function and get the cvd-simulated colors in return: https://colorspace.r-forge.r-project.org/reference/simulate_cvd.html

daattali commented 1 year ago

Thanks, {colorspace} has very minimal dependencies so I would be happy to use it!

The other part of this feature is coming up with a clear, clean, user friendly UI, and then of course implementing it cleanly and testing :)