devtools::install_github("bahlolab/ggwehi")
library(tidyverse)
library(ggwehi)
diamonds %>%
ggplot(aes(x = cut, fill = clarity)) +
geom_bar() +
scale_fill_wehi() +
ggtitle('scale_fill_wehi()')
set.seed(1)
tibble(state = c(rbind(str_c(1:5, 'A'), str_c(1:5, 'B'))),
class = str_extract(state, '^.'),
condition = str_extract(state, '.$'),
value = abs(rnorm(length(class)))) %>%
ggplot(aes(class, value, fill = state)) +
geom_col() +
scale_fill_wehi_paired() +
ggtitle('scale_fill_wehi_paired()')
set.seed(2)
diamonds %>%
sample_n(5000) %>%
ggplot(aes(x = cut, y = carat, col = price)) +
geom_jitter(height = 0, width = 0.35) +
geom_boxplot(fill = NA, outlier.colour = NA, col = 'black') +
scale_colour_wehi_continuous() +
ggtitle('scale_colour_wehi_continuous()')
scale_fill_wehi()
/scale_colour_wehi()
- Supports up to 8 different colours
- Note:
na.value
is set toggwehi::wehi_grey
(grey from wehi_primary)
scale_fill_wehi_paired()
/scale_colour_wehi_paired()
- Supports up to 8 pairs, with 16 different colours
- Note: This will only work if the aesthetic is such that when
alphabetically sorted the pairs are adjacent to one another, and
all pairs are complete. For a more general solution use
scale_fill_manual(values = x)
where x is a named vector of values from ggwehi::wehi_paired.
scale_fill_wehi_continuous()
/scale_colour_wehi_continuous()
scales::show_col(wehi_primary)
scales::show_col(wehi_secondary)
scales::show_col(wehi_extended)
scales::show_col(wehi_paired)
scales::show_col(wehi_continous()(seq(0,1,1/15)))