show_colors | R Documentation |
R
includes 657 named colors
. This is a convenience
function to locate specific ones quickly.
Find a color by index in the plot created with show_colors()
by
first locating the desired color and summing the row and column indices
corresponding to its position.
Return a color name or index by giving the index or name, respectively,
optionally, plotting one or more. Search for all colors with a pattern,
such as "red|orange"
, and return all matches, optionally plotting.
show_colors(..., plot = FALSE)
... |
integer(s) in |
plot |
logical; if |
If ...
is missing, a plot will be drawn. If an integer is given, the
color name will be returned; if a color name string is given, the index
will be returned. For the latter two options, no plot is drawn by default
but will be if plot = TRUE
. If one or more strings are given and
one contains a "?"
, all color names matching the input will be
returned and optionally plotted.
show_pch
; colors
; waffle
;
tcol
## typical usage
show_colors()
show_colors(5, 6, 544)
show_colors('blue4', 'dodgerblue2')
## search for color names or numbers
show_colors(grep('red|orange', colors()), plot = TRUE)
## shorthand
show_colors('?red', 'orange')
show_colors('?red|orange', plot = TRUE)
## this function is its own inverse
show_colors(81)
show_colors('darkgreen')
x <- show_colors(sample(657, 10))
identical(x, show_colors(show_colors(x)))
## these plots are identical
show_colors(x, plot = TRUE)
show_colors(show_colors(x), plot = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.