Tricolore {tricolore} | R Documentation |
Ternary Balance Color Scale
Description
Color-code three-part compositions with a ternary balance color scale and return a color key.
Usage
Tricolore(
df,
p1,
p2,
p3,
center = rep(1/3, 3),
breaks = ifelse(identical(center, rep(1/3, 3)), 4, Inf),
hue = 0.2,
chroma = 0.7,
lightness = 0.8,
contrast = 0.4,
spread = 1,
legend = TRUE,
show_data = TRUE,
show_center = ifelse(identical(center, rep(1/3, 3)), FALSE, TRUE),
label_as = ifelse(identical(center, rep(1/3, 3)), "pct", "pct_diff"),
crop = FALSE,
input_validation = TRUE
)
Arguments
df |
Data frame of compositional data. |
p1 |
Column name for variable in df giving first proportion of ternary composition (string). |
p2 |
Column name for variable in df giving second proportion of ternary composition (string). |
p3 |
Column name for variable in df giving third proportion of ternary composition (string). |
center |
Ternary coordinates of the color scale center. (default = 1/3,1/3,1/3). NA puts center over the compositional mean of the data. |
breaks |
Number of per-axis breaks in the discrete color scale. An integer >1. Values above 99 imply no discretization. |
hue |
Primary hue of the first ternary element (0 to 1). |
chroma |
Maximum possible chroma of mixed colors (0 to 1). |
lightness |
Lightness of mixed colors (0 to 1). |
contrast |
Lightness contrast of the color scale (0 to 1). |
spread |
The spread of the color scale. Choose values > 1 to focus the color scale on the center. |
legend |
Should a legend be returned along with the colors? (default=TRUE) |
show_data |
Should the data be shown on the legend? (default=TRUE) |
show_center |
Should the center be shown on the legend? (default=FALSE if center is at c(1/3, 1/3, 1/3), otherwise TRUE) |
label_as |
"pct" for percent-share labels or "pct_diff" for percent-point-difference from center labels. (default='pct' if center is at c(1/3, 1/3, 1/3), otherwise 'pct_diff') |
crop |
Should the legend be cropped to the data? (default=FALSE) |
input_validation |
Should the function arguments be validated? (default=TRUE) |
Value
legend=FALSE: A vector of rgbs hex-codes representing the ternary balance scheme colors.
legend=TRUE: A list with elements "rgb" and "key".
Examples
P <- as.data.frame(prop.table(matrix(runif(3^6), ncol = 3), 1))
Tricolore(P, 'V1', 'V2', 'V3')