-
Notifications
You must be signed in to change notification settings - Fork 1
/
palette-color-blind.R
40 lines (36 loc) · 966 Bytes
/
palette-color-blind.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#' Provide Colorblind Compliant Colors
#'
#' 8 Hex RGB color definitions suitable for charts for colorblind people.
#'
#' @export
color_blind <- function() {
c(
"#000000", "#E69F00", "#56B4E9",
"#009E73", "#F0E442", "#0072B2",
"#D55E00", "#CC79A7"
)
}
#' Provide Colorblind Compliant Colors
#'
#' @param theme This defaults to `td` and that is the only allowed value
#' @param ... Data passed to the function
#'
#' @export
td_scale_fill_colorblind <- function(..., theme = "td") {
pal <- switch(theme,
"td" = unname(color_blind()) |> rep(100)
)
ggplot2::scale_fill_manual(values = pal)
}
#' Provide Colorblind Compliant Colors
#'
#' @param theme This defaults to `td` and that is the only allowed value
#' @param ... Data passed to the function
#'
#' @export
td_scale_color_colorblind <- function(..., theme = "td") {
pal <- switch(theme,
"td" = unname(color_blind()) |> rep(100)
)
ggplot2::scale_color_manual(values = pal)
}