scale_cr: Custom color palette scale functions for ggplot2

scale_crR Documentation

Custom color palette scale functions for ggplot2

Description

Uses the provided color palette for the color or fill aesthetics of a ggplot2 object. The function will use scale_discrete when the colors are selected with ncol or colors and will use scale_manual when the colors are selected with names.

Usage

scale_color_cr(
  palette = "default",
  ncol = NULL,
  colors = NULL,
  species = NULL,
  alpha = 1,
  ...
)

scale_fill_cr(
  palette = "default",
  ncol = NULL,
  colors = NULL,
  species = NULL,
  alpha = 1,
  ...
)

Arguments

palette

Character vector of length 1 defining the palette to select colors from; use pal_names() to see a list of available palettes, default palette is named "default"

ncol

Range of colors to select from palette; if only one number is provided, it will be the number of colors selected; can only use one selection technique

colors

Names of colors to select from palette, given as a character vector; can only use one selection technique

species

Names of species to select from palette (e.g., "IL6" or "Tocilizumab"), given as a character vector; can only use one selection technique

alpha

new alpha level in [0,1]. If alpha is NA, existing alpha values are preserved. Default is 1. Uses alpha() to set the alpha value

...

Additional parameters for discrete_scale

Examples

library(ggplot2)

df <- data.frame(x = 1:5, y = 1:5, z = c("IL6", "IL8", "IL6R", "IL6", "IL8"))
p <- ggplot(df, aes(x, y, color = z)) + geom_point()

# Using the colors without name-matching
p + scale_color_cr(palette = "receptors")

# Matching the colors to the species names
p + scale_color_cr(palette = "receptors", species = unique(df$z))


christyray/crthemes documentation built on April 14, 2023, 11:18 p.m.