View source: R/TransformColors.R
TransformColors | R Documentation |
TransformColors modifies a vector of colors in the HSV or RGB spaces (see Details section).
TransformColors(
v,
delta.H = NULL,
S.range = NULL,
V.range = NULL,
R.range = NULL,
G.range = NULL,
B.range = NULL
)
v |
a standard R color vector or a ColorParameters or GroupParameters object defined by DefineColorMap or by DefineGroupStyles. |
delta.H |
vector of delta hue values (default = NULL, no effect). |
S.range |
the targeted saturation range (default = NULL, no effect). |
V.range |
the targeted value range (default = NULL, no effect). |
R.range |
targeted range for the red component (default = NULL, no effect). |
G.range |
targeted range for the green component (default = NULL, no effect). |
B.range |
targeted range for the blue component (default = NULL, no effect). |
If both HSV and RGB transformation parameters are provided, the colors will be modified first in HSV space, then in RGB space. Note that TransformColors does not alter transparency values. When providing a ColorParameters or GroupParameters object as input, TransformColors returns color mapping parameters with modified threshold colors or group style parameters with modified group-associated colors.
TransformColors
returns either a vector of R colors or
a ColorParameters or GroupParameters object depending on the type of its
input argument v
.
DefineColorMap, DefineGroupStyles, MakeColors
layout(matrix(1:4, 2, 2))
col.prm <- DefineColorMap(c(1,101), c("purple", "yellow"), levels = 5)
image(matrix(1:100, 10), col = MakeColors(1:100, parameters = col.prm))
# Transform to grey levels
tst <- TransformColors(col.prm, S.range = 0)
image(matrix(1:100, 10), col = MakeColors(1:100, parameters = tst))
# Changes hues to complementary colors
tst <- TransformColors(col.prm, delta.H = 180)
image(matrix(1:100, 10), col = MakeColors(1:100, parameters = tst))
# Maximize constrast
tst <- TransformColors(col.prm, V.range = c(0, 1))
image(matrix(1:100, 10), col = MakeColors(1:100, parameters = tst))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.