hue | R Documentation |
Get the hues (angles around the color wheel, in [0,360]) of a vector of colors.
hue(x, model = "hsv", modulo = TRUE)
x |
vector of colors (specified as hex strings or named R colors), or numerical hues, or a mix thereof. |
model |
string defining the color model; valid models are the ones containing a hue component: |
modulo |
logical, whether to restrict the hues in [0,360]. |
A vector of hue angles, in [0,360] if modulo is TRUE
.
channel
used internally, to extract the hue channel.
# various input formats for x hue(c("#F55D5B", "#16b2b4", "#6A9F16")) hue(c("red", "green", "blue")) hue(c(0, 10, 365)) hue(c(10, "#B55FFC", "pink", NA, 365)) # It is possible to reconstruct colors similar to the original ones # based on the extracted hue, by providing the other components cols <- c("firebrick", "gold", "limegreen", "dodgerblue", "navy", "mediumpurple") show_col(cols, hsv(h=hue(cols, model="hsv"), s=0.9, v=1), hsl(h=hue(cols, model="hsl"), s=1, l=0.6), hcl(h=hue(cols, model="hcl"), c=1, l=0.8) ) # = works, but is a bit less predictable with hcl().
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.