make_color_set: Create a set of colors for use in graphs

View source: R/make_color_set.R

make_color_setR Documentation

Create a set of colors for use in graphs

Description

Create a set of colors for use in graphs

Usage

make_color_set(color_set, num_colors)

Arguments

color_set

the set of colors to use. Options:

"default"

a set of colors from Cynthia Brewer et al. from Penn State that are friendly to those with red-green colorblindness. The first three colors are green, orange, and purple. This can also be referred to as "Brewer set 2". If there are only two unique values in the colorBy_column, then Brewer set 1 will be used since red and blue are still easily distinguishable but also more aesthetically pleasing than green and orange.

"Brewer set 1"

colors selected from the Brewer palette "set 1". The first three colors are red, blue, and green.

"ggplot2 default"

the default set of colors used in ggplot2 graphs (ggplot2 is an R package for graphing.)

"rainbow"

colors selected from a rainbow palette. The default palette is limited to something like 6 colors, so if you have more than that, that's when this palette is most useful. It's not very useful when you only need a couple of colors.

"blue-green"

a set of blues fading into greens. This palette can be especially useful if you are comparing a systematic change in some continuous variable – for example, increasing dose or predicting how a change in intrinsic solubility will affect concentration-time profiles – because the direction of the trend will be clear.

"blues"

a set of blues fading from baby to navy. Like "blue-green", this palette can be especially useful if you are comparing a systematic change in some continuous variable.

"greens"

a set of greens from chartreuse to forest. Great for showing systematic changes in a continuous variable.

"purples"

a set of purples from lavender to aubergine. Great for showing systematic changes in a continuous variable.

"reds"

a set of reds from pink to brick. Great for showing systematic changes in a continuous variable.

"Tableau"

uses the standard Tableau palette; requires the "ggthemes" package

"viridis"

from the eponymous package by Simon Garnier and ranges colors from purple to blue to green to yellow in a manner that is "printer-friendly, perceptually uniform and easy to read by those with colorblindness", according to the package author

a character vector of colors

If you'd prefer to set all the colors yourself to exactly the colors you want, you can specify those colors here. An example of how the syntax should look: color_set = c("dodgerblue3", "purple", "#D8212D") or, if you want to specify exactly which item in colorBy_column gets which color, you can supply a named vector. For example, if you're coloring the lines by the compound ID, you could do this: color_set = c("substrate" = "dodgerblue3", "inhibitor 1" = "purple", "primary metabolite 1" = "#D8212D"). If you'd like help creating a specific gradation of colors, please talk to a member of the R Working Group about how to do that using colorRampPalette.

num_colors

the number of colors needed

Value

a character vector of color names

Examples

make_color_set("blues", 10)
make_color_set("Tableau", 3)

# You can see the colors with show_col from the scales package.
make_color_set("viridis", 5) %>% scales::show_col()
make_color_set("Brewer set 1", 4) %>% scales::show_col()



shirewoman2/Consultancy documentation built on Feb. 18, 2025, 10 p.m.