Colorblind-friendly palette?

3,183 views
Skip to first unread message

Winston Chang

unread,
May 20, 2009, 11:17:10 PM5/20/09
to ggplot2
I just came across a page on making presentations that don't cause problems for those that are colorblind:
http://jfly.iam.u-tokyo.ac.jp/color/

On that page, there is a set of colors that is both aesthetically pleasing  and colorblind-friendly. Hadley - how do you feel about adding a color scale like this? I think it would be beneficial -- perhaps even as the default color set -- since something like 8% of men have some form of colorblindness. I recently showed a colorblind friend a graph generated with ggplot2, and he had a bit of difficulty distinguishing the reds and greens (he could see that there was a difference, but the difference wasn't obvious).

I'm looking at the code for scale-discrete-colour.r and I might try playing it, but I can't say that I fully understand how it works just yet.

-Winston


pallete.jpg


pallete.jpg

JiHO

unread,
May 21, 2009, 12:20:45 AM5/21/09
to Winston Chang, ggplot2

Just so you know, in ggplot you already have scale_color_brewer which
provides color palettes from color brewer:
http://www.personal.psu.edu/cab38/ColorBrewer/ColorBrewer.html
By going on the website, you can preview the palettes and in the
bottom left corner you have a rating of the palette for color-
blindness, photocopy, beamer projection etc. Many sequential and
diverging palettes are color-blind friendly already but, admittedly,
not many of the qualitative ones are.

JiHO
---
http://jo.irisson.free.fr/

Tobias Verbeke

unread,
May 21, 2009, 1:28:37 AM5/21/09
to JiHO, Winston Chang, ggplot2

and for the record: the dichromat package by Thomas Lumley has
color schemes " suitable for people with deficient or anomalous
red-green vision". It also has a function dichromat that takes
in regular R colors and shows the effect of color-blindness
(by collapsing red-green distinctions).

library(dichromat)
?dichromat

HTH,
Tobias


baptiste auguie

unread,
May 21, 2009, 6:47:17 AM5/21/09
to Tobias Verbeke, ggplot2
Interesting, thanks. It could be nice to use the palettes from
dichromat::colorschemes as an alternative to the scale_colour_brewer
option in ggplot2. I'll try that later and if it works I'll add it to
ggplotpp for wider testing.

Another interesting feature to borrow from dichromat would be a
function, say test_colour() that you could add to a ggplot to check
the appearance for colour blind people, as in,

p <- qplot(...)

# testing
p + test_colour()

This one I'm not sure how to proceed though...

Perhaps a call to dichromat() within grid.edit with a search for
colour as a regular expression?

baptiste

baptiste auguie

unread,
May 21, 2009, 10:08:07 AM5/21/09
to ggplot2
Hi all,

I've started playing around with the palettes from dichromat,

http://ggplot2.wik.is/User:Bapt/Utilities/Dichromat_colour_palettes

So far I've rearranged the data to make it look more like brewer
palettes. Next step is to finish up and test the new scale.

Comments and ideas are welcome.

baptiste

--

_____________________________

Baptiste Auguié

School of Physics
University of Exeter
Stocker Road,
Exeter, Devon,
EX4 4QL, UK

Phone: +44 1392 264187

http://newton.ex.ac.uk/research/emag
______________________________

baptiste auguie

unread,
May 22, 2009, 5:00:38 PM5/22/09
to ggplot2
scale_colour_dichromat should now be on r-forge (well tomorrow for the
binary package ggplotpp). I haven't really tested it much so expect
many errors,

library(dichromat)
library(ggplotpp)

dsamp <- diamonds[sample(nrow(diamonds), 1000), ]
str(dsamp)
d <- qplot(carat, price, data=dsamp, colour=cut)

d + scale_colour_dichromat(type="div")
d + scale_colour_dichromat(type="div", palette=2)
d + scale_colour_dichromat(type="div", palette=3)
d + scale_colour_dichromat(type="div", palette=4)
d + scale_colour_dichromat(type="div", palette=5)
d + scale_colour_dichromat(type="div", palette=6)
d + scale_colour_dichromat(type="div", palette=7)
d + scale_colour_dichromat(type="div", palette=8)

d + scale_colour_dichromat(type="seq")
d + scale_colour_dichromat(type="step")
d + scale_colour_dichromat(type="cat")


I'd be curious to hear ideas on how to implement the test_colour()
function described below.

baptiste


On Thu, May 21, 2009 at 4:08 PM, baptiste auguie

Reply all
Reply to author
Forward
0 new messages