Designing Color Blindness friendly graphs

What is Color Blindess?

  • Color blindness is a reduced ability to distinguish between colors when compared to the standard for normal human color vision.
  • Color blindness affects 1 in 12 men and 1 in 200 women.
  • Sometimes color blindness is called “Red-Green Color blindness” since red and green are the two colors that are typically most difficult to distinguish by color blind individuals. Color blindness also makes it difficult to distinguish blues and yellows as well.

Color Brewer Online

https://colorbrewer2.org

RColorBrewer Package

display.brewer.all(n,type,colorblindFriendly)

Input:

  • n - number of colors you want
  • type - type of data (qual for qualitative,seq for sequential,or div for diverging)
  • colorblindFriendly - TRUE or FALSE (set TRUE to return color blind friendly colors)

Output:

  • Visual representation of available colors. Each set has a name, which can be called in code.
display.brewer.all(n=5,type='div',colorblindFriendly=TRUE)

brewer.pal(n,name)
Input:

  • n - number of colors you want
  • name - name of color palette, which can be found using display.brewer.all()

Output:

  • Hex color codes
brewer.pal(5,"Accent")
## [1] "#7FC97F" "#BEAED4" "#FDC086" "#FFFF99" "#386CB0"

Qualitative Data

Color Blind Friendly Options

display.brewer.all(n=NULL,type='qual', colorblindFriendly=TRUE)

Graph

ggplot(mtcars, aes(x=as.factor(cyl), fill=as.factor(cyl) )) + 
  geom_bar( ) +
  scale_fill_brewer(palette = "Dark2") +
  theme(legend.position="none")

Sequential Example

Color Blind Friendly Options

display.brewer.all(n=NULL,type='seq',colorblindFriendly=TRUE)

Graph

ggplot(data = midwest, aes(x = area, y = poptotal)) + 
geom_point(aes(col=state, size=popdensity)) + 
  ggtitle("Area Vs Population") +
  theme(plot.title = element_text(hjust = 0.5)) +
  scale_color_brewer(palette='YlOrRd')