Title: | Color Scheme Helpers |
---|---|
Description: | Hexadecimal codes are typically used to represent colors in R. Connecting these codes to their colors requires practice or memorization. 'palette' provides a 'vctrs' class for working with color palettes, including printing and plotting functions. The goal of the class is to place visual representations of color palettes directly on or, at least, next to their corresponding character representations. Palette extensions also are provided for data frames using 'pillar'. |
Authors: | Christopher T. Kenny [aut, cre] |
Maintainer: | Christopher T. Kenny <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.0.3 |
Built: | 2024-11-10 03:44:39 UTC |
Source: | https://github.com/christopherkenny/palette |
Generic function to control the brightness of a palette.
darken(x, amount = 0.1, ...) lighten(x, amount = 0.1, ...) ## Default S3 method: darken(x, amount = 0.1, ...) ## S3 method for class 'palette' darken(x, amount = 0.1, ...) ## Default S3 method: lighten(x, amount = 0.1, ...) ## S3 method for class 'palette' lighten(x, amount = 0.1, ...)
darken(x, amount = 0.1, ...) lighten(x, amount = 0.1, ...) ## Default S3 method: darken(x, amount = 0.1, ...) ## S3 method for class 'palette' darken(x, amount = 0.1, ...) ## Default S3 method: lighten(x, amount = 0.1, ...) ## S3 method for class 'palette' lighten(x, amount = 0.1, ...)
x |
A vector of colors |
amount |
A numeric value to control the brightness of the palette |
... |
Additional arguments passed to other methods. Currently ignored. |
A palette vector with the brightness adjusted
darken(palette(roygbiv)) lighten(palette(roygbiv))
darken(palette(roygbiv)) lighten(palette(roygbiv))
A palette
is a class for color palettes built on vctrs
. It is represented
as a character vector of hexadecimal color codes. Named colors (like 'red'
)
are translated to hexadecimal color codes.
palette(x = character()) validate_palette(x) is_palette(x) as_palette(x)
palette(x = character()) validate_palette(x) is_palette(x) as_palette(x)
x |
A character vector of colors |
a palette vector
palette(roygbiv)
palette(roygbiv)
Browse a palette on coolors.co
palette_browse(x) palette_browse_url(x)
palette_browse(x) palette_browse_url(x)
x |
A palette |
A URL to the palette
palette_browse(roygbiv)
palette_browse(roygbiv)
This function takes a URL from either <coolors.co> or <colorhunt.co> and returns the palette.
palette_decode_url(x)
palette_decode_url(x)
x |
A URL from either 'coolors.co' or 'colorhunt.co' |
a vector of type palette
palette_decode_url('https://coolors.co/ff4444-ffae4d-ffff60-50ff50-3939fa') palette_decode_url('https://www.colorhunt.co/palette/b5c0d0ccd3caf5e8ddeed3d9')
palette_decode_url('https://coolors.co/ff4444-ffae4d-ffff60-50ff50-3939fa') palette_decode_url('https://www.colorhunt.co/palette/b5c0d0ccd3caf5e8ddeed3d9')
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.
palette_function(x)
palette_function(x)
x |
a palette |
a function which takes an integer n
and returns a vector of n
colors
palette_function(palette(roygbiv))(10)
palette_function(palette(roygbiv))(10)
Plot Palette Colors
plot_palette(x, use_names = TRUE, use_ggplot = TRUE)
plot_palette(x, use_names = TRUE, use_ggplot = TRUE)
x |
a palette |
use_names |
Should the names of the palette be used as labels? Default: |
use_ggplot |
Should the plot be made with ggplot2 if available? Default: |
A ggplot
(if ggplot2 is available) or base plot of the palette
plot_palette(roygbiv)
plot_palette(roygbiv)
Rainbow Colors
roygbiv
roygbiv
character vector of 7 hex codes
palette(roygbiv)
palette(roygbiv)
Generic function to control the saturation of a palette.
saturate(x, amount = 0.1, ...) desaturate(x, amount = 0.1, ...) ## Default S3 method: saturate(x, amount = 0.1, ...) ## S3 method for class 'palette' saturate(x, amount = 0.1, ...) ## Default S3 method: desaturate(x, amount = 0.1, ...) ## S3 method for class 'palette' desaturate(x, amount = 0.1, ...)
saturate(x, amount = 0.1, ...) desaturate(x, amount = 0.1, ...) ## Default S3 method: saturate(x, amount = 0.1, ...) ## S3 method for class 'palette' saturate(x, amount = 0.1, ...) ## Default S3 method: desaturate(x, amount = 0.1, ...) ## S3 method for class 'palette' desaturate(x, amount = 0.1, ...)
x |
A vector of colors |
amount |
A numeric value to control the saturation of the palette |
... |
Additional arguments passed to other methods. Currently ignored. |
A palette vector with the saturation adjusted
saturate(palette(roygbiv)) desaturate(palette(roygbiv))
saturate(palette(roygbiv)) desaturate(palette(roygbiv))