adjustcolorHSV: Adjust Colors in One or More Directions Conveniently.

Description Usage Arguments Details Value Examples

View source: R/adjustcolorHSV.R

Description

Adjust or modify a vector of colors by "turning knobs" on one or more coordinates in (h,s,v,α) space, typically by up or down scaling them.

Usage

1
2
3
adjustcolorHSV(col, alpha.f = 1, h.f = 1, s.f = 1, v.f = 1,
  offset = c(0, 0, 0, 0), transform = diag(c(h.f, s.f, v.f, alpha.f)),
  h = NULL, s = NULL, v = NULL, alpha = NULL)

Arguments

col

vector of colors, in any format that col2rgb() accepts

alpha.f, h.f, s.f, v.f

factors scaling the opacity, hue, saturation and value of col

offset

a length 4 numeric vector specifying the linear offset applied to the hue, saturation, value and alpha values

transform

a 4x4 diagonal matrix specifying the scaling applied to the hue, saturation, value and alpha values

h, s, v, alpha

fixed vlues for hue, saturation, value and alpha. Overrides any corresponding scaling factor or offset

Details

Essentially an HSV version of the RGB-based adjustcolor. One important distinction is that the h.f value wraps around to fit the [0, 1] range, rather than simply "clamping" it between 0 and 1.

Value

A character vector the same length as col contaning color data in standard hexadeximal RGBA format.

Examples

1
2
3
4
5
6
7
# Halve the saturation and value of the default palette colours
plot(2:8, cex=5, lwd=4, pch=21, bg=2:8, 
  col=adjustcolorHSV(2:8, s.f=0.5, v.f=0.6))

# Offset the hue of the default palette colours by 0.5, inverting the colours
plot(2:8, cex=5, lwd=4, pch=21, bg=2:8, 
  col=adjustcolorHSV(2:8, offset=c(0.5, 0, 0, 0)))

AkselA/R-ymse documentation built on March 21, 2020, 9:52 a.m.