library(ggplot2)
library(farver)
library(colorspace)
<- function(colors, ncol = 3, label = TRUE) {
check_colorblindness <- length(colors)
ncolors <- ceiling(ncolors / ncol)
nrow <- c("Original", "Deutan", "Protan", "Tritan")
cond <- length(cond)
ncond
<- data.frame(color = c(colors, deutan(colors), protan(colors), tritan(colors)),
df cond = rep(cond, each = ncolors),
x = rep(rep(1:ncol, length.out = ncolors), times = ncond),
y = rep(rep(1:nrow, each = ncol)[1:ncolors], times = ncond)) %>%
mutate(cond = factor(cond, levels = .env$cond))
<- ggplot(df, aes(x, y, fill = I(color))) +
g geom_tile(color = "black", size = 1.3) +
theme_void() +
coord_equal() +
facet_wrap(~cond, ncol = 2) +
scale_y_reverse()
if(label) {
+ geom_text(aes(label = color, color = I(label_col)),
g data = function(data) data %>%
filter(cond == "Original") %>%
mutate(hcl = decode_colour(colors, to = "hcl"),
label_col = ifelse(hcl[, "l"] > 50, "black", "white")))
else {
}
g
} }
Colorblind checks for qualitative palettes
R
color
Checking the color blind friendliness of a number of qualitative palettes.
Function to generate plot for colorblind friendly check
Name | Source | Colors | # of colors | Palette |
---|---|---|---|---|
High contrast | Paul Tol | #FFFFFF, #DDAA33, #BB5566, #004488, #000000 | 5 | |
Pale | Paul Tol | #BBCCEE, #CCEEFF, #CCDDAA, #EEEEBB, #FFCCCC, #DDDDDD | 6 | |
Dark | Paul Tol | #222255, #225555, #225522, #666633, #663333, #555555 | 6 | |
Bright | Paul Tol | #4477AA, #66CCEE, #228833, #CCBB44, #EE6677, #AA3377, #BBBBBB | 7 | |
Vibrant | Paul Tol | #0077BB, #33BBEE, #009988, #EE7733, #CC3311, #EE3377, #BBBBBB | 7 | |
Medium constrast | Paul Tol | #FFFFFF, #EECC66, #EE99AA, #6699CC, #997700, #994455, #004488, #000000 | 8 | |
Okabe Ito | Okabe Ito | #E69F00, #56B4E9, #009E73, #F0E442, #0072B2, #D55E00, #CC79A7, #000000 | 8 | |
Light | Paul Tol | #77AADD, #99DDFF, #44BB99, #BBCC33, #AAAA00, #EEDD88, #EE8866, #FFAABB, #DDDDDD | 9 | |
Muted | Paul Tol | #332288, #88CCEE, #44AA99, #117733, #999933, #DDCC77, #CC6677, #882255, #AA4499, #DDDDDD | 10 | |
Safe | rcartocolor |
#88CCEE, #CC6677, #DDCC77, #117733, #332288, #AA4499, #44AA99, #999933, #882255, #661100, #6699CC, #888888 | 12 | |
Monash primary | Monash | #006DAE, #000000, #FFFFFF, #5A5A5A, #969696, #E6E6E6 | 6 | |
Monash secondary | Monash | #027EB6, #746FB2, #9651A0, #C8008F, #ee64a4, #EE0220, #D93F00, #795549, #6F7C4D, #008A25 | 10 |
R code for easy copying
### High contrast
c("#FFFFFF", "#DDAA33", "#BB5566", "#004488", "#000000")
### Pale
c("#BBCCEE", "#CCEEFF", "#CCDDAA", "#EEEEBB", "#FFCCCC", "#DDDDDD"
)
### Dark
c("#222255", "#225555", "#225522", "#666633", "#663333", "#555555"
)
### Bright
c("#4477AA", "#66CCEE", "#228833", "#CCBB44", "#EE6677", "#AA3377",
"#BBBBBB")
### Vibrant
c("#0077BB", "#33BBEE", "#009988", "#EE7733", "#CC3311", "#EE3377",
"#BBBBBB")
### Medium constrast
c("#FFFFFF", "#EECC66", "#EE99AA", "#6699CC", "#997700", "#994455",
"#004488", "#000000")
### Okabe Ito
c("#E69F00", "#56B4E9", "#009E73", "#F0E442", "#0072B2", "#D55E00",
"#CC79A7", "#000000")
### Light
c("#77AADD", "#99DDFF", "#44BB99", "#BBCC33", "#AAAA00", "#EEDD88",
"#EE8866", "#FFAABB", "#DDDDDD")
### Muted
c("#332288", "#88CCEE", "#44AA99", "#117733", "#999933", "#DDCC77",
"#CC6677", "#882255", "#AA4499", "#DDDDDD")
### Safe
c("#88CCEE", "#CC6677", "#DDCC77", "#117733", "#332288", "#AA4499",
"#44AA99", "#999933", "#882255", "#661100", "#6699CC", "#888888"
)
### Monash primary
c(blue = "#006DAE", black = "#000000", white = "#FFFFFF", gray80 = "#5A5A5A",
gray50 = "#969696", gray10 = "#E6E6E6")
### Monash secondary
c(blue = "#027EB6", purple = "#746FB2", fuchsia = "#9651A0",
ruby = "#C8008F", pink = "#ee64a4", red = "#EE0220", orange = "#D93F00",
umber = "#795549", olive = "#6F7C4D", green = "#008A25")