Learn R Programming

tntpr (version 1.2.1)

tntp_colors: TNTP Brand Colors

Description

Translate human friendly TNTP brand color names like "medium_blue" into accurate hex values for use in plotting. This function can also be used to show a named vector of all available TNTP brand colors and values. Use show_tntp_colors() to quickly visualize selected colors in the plot window. For often used palettes of TNTP colors, see tntp_palette().

Usage

tntp_colors(...)

show_tntp_colors( ..., pattern = NULL, labels = TRUE, borders = NULL, cex_label = 1, ncol = NULL )

Value

  • tntp_colors() returns a character vector of color codes

  • show_tntp_colors() returns nothing

Arguments

...

Supply quoted TNTP color names to return. If no colors are specified, returns all available colors.

pattern

Optional regular expression. If provided, will return only brand colors that match the regular expression

labels

Logical. Label colors with names and hex values?

borders

Border color for each tile. Default uses par("fg"). Use border = NA to omit borders.

cex_label

Size of printed labels, as multiplier of default size.

ncol

Number of columns. If not supplied, tries to be as square as possible.

Examples

Run this code

library(ggplot2)

# Use tntp_colors() to retrieve a single color...
ggplot(mtcars, aes(wt, mpg)) +
  geom_point(color = tntp_colors('green'))

#... multiple colors ...
ggplot(iris, aes(Sepal.Length, Sepal.Width, color = Species)) +
  geom_point() +
  scale_color_manual(values = tntp_colors('green', 'navy', 'red'))

#... or a list of all possible TNTP brand colors
tntp_colors()

# Use show_tntp_colors() to quickly see brand colors in the plotting window
show_tntp_colors('mint', 'moss', 'green')

# You can also use a pattern to return similar colors
show_tntp_colors(pattern = 'green')

# You can see all colors (and names) by running it with no arguments
show_tntp_colors()

Run the code above in your browser using DataLab