Skip to content

Colour scales for ggplot2 based on the WEHI colour palette

Notifications You must be signed in to change notification settings

bahlolab/ggwehi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ggwehi: Colour scales for ggplot2 based on the WEHI colour palette

Installation

devtools::install_github("bahlolab/ggwehi")

Examples

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 functions

  • scale_fill_wehi()/scale_colour_wehi()
    • Supports up to 8 different colours
    • Note: na.value is set to ggwehi::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()

Palettes

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)))

About

Colour scales for ggplot2 based on the WEHI colour palette

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages