Create Colorblind friendly corporate palette
mrjoh3 opened this issue · comments
using the current corporate colours define colour palettes that maximise colour contrast. We will need palettes of different lengths
I have already assessed the current colours and selected 7 where at least one pairwise contrast comparison is above 4.5. When creating palettes with less colours we can use a similar approach
# pairwise comparison of current palette
mt <- as.matrix(
c(
"#14826D",
"#62BB46",
"#C0E4B5",
"#BCD3EF",
"#1D9EC3",
"#2A6FA2",
"#004676",
"#1F1547",
"#53565A",
"#745ECF"
)
)
cd <- sapply(mt, colorspace::contrast_ratio, mt)
rownames(cd) <- mt
# select contrast above 4.5
cond <- cd > 4.5 & upper.tri(cd, FALSE)
pos <- which(cond, arr.ind = TRUE)
# convert to dataframe and extract unique colours
df <- data.frame(values = cd[pos], ind = rownames(cd)[pos[,1]], pp = rownames(cd)[pos[,2]])
contrast_pal <- unique(c(df$ind, df$pp))
I have then checked this colour selection for colour blindness impact using the website below:
PR approved, this issue can be closed.