palette_function {palette} | R Documentation |
Build a palette function
Description
Creates a palette function for use within ggplot2
as an argument to discrete_scale
.
If the number of colors requested is greater than the length of the palette,
the palette will be repeated. If the number of colors requested is less than the
length of the palette, the palette will be truncated. This is done explicitly, as
vctrs
recycling purposefully does not recycle to partial lengths, like a vector of
size 10 to a vector of size 3 or 13.
Usage
palette_function(x)
Arguments
x |
a palette |
Value
a function which takes an integer n
and returns a vector of n
colors
Examples
palette_function(palette(roygbiv))(10)
[Package palette version 0.0.2 Index]