Learn R Programming

palette (version 0.0.2)

palette_function: 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)

Value

a function which takes an integer n and returns a vector of n colors

Arguments

x

a palette

Examples

Run this code
palette_function(palette(roygbiv))(10)

Run the code above in your browser using DataLab