| subset_colors | R Documentation |
Subset a vector of colors using one or more color attributes
subset_colors(
x,
...,
alpha = TRUE,
byCols = NULL,
return_type = c("colors", "df")
)
x |
|
... |
any valid criteria to subset the color |
alpha |
|
byCols |
|
return_type |
|
The input colors in x are converted internally to a data.frame
with colnames added by relevant helper functions.
"num" contains the integer index of the input vector x.
"hex" contains character values with hexadecimal colors
including alpha. If the input x is "red" then the hex value
will be converted to "#FF0000FF".
character vector of colors that meet the filter criteria.
When return_type="df" the returned object is a data.frame with
the subset columns included for review.
jamba::col2hcl()"H" contains color hue as values from 0 to 360.
"C" contains color chroma (aka saturation) ranging from 0 up to 200,
where typical "full saturation" is represented as values above 100.
"L" contains color luminance (brightness/lightness) ranging from
0 to 100.
"alpha" the alpha transparency, ranging from 0 (fully transparent)
to 1 (fully opaque, not transparent).
grDevices::col2rgb()"red" contains the red color channel, values range from 0 to 255.
"green" contains the green color channel, values range from 0 to 255.
"blue" contains the blue color channel, values range from 0 to 255.
jamba::col2hsv()"h" contains color hue as values from 0 to 1. Note these values
may not map directly to color hue obtained from jamba::col2hcl().
"s" contains color saturation with values from 0 to 1.
"v" contains color vibrance (brightness/lightness) with values
from 0 to 1.
Other colorjam sort:
colors_to_df(),
sort_colors()
Other colorjam core:
blend_colors(),
closestRcolor(),
color_complement(),
colors_to_df(),
group2colors(),
rainbowJam(),
sort_colors()
# subset for blue colors
jamba::showColors(subset_colors(colors(), H > 200 & H < 265 & C > 80))
# subset for saturated colors
jamba::showColors(subset_colors(colors(), C > 120))
# subset for saturated colors then sort by hue
jamba::showColors(subset_colors(colors(), C > 120, byCols=c("H", "-C", "-L")))
# review the data.frame itself
subset_colors(colors(), C > 135, return_type="df")
# for curiosity, compare H to h
colors_df <- subset_colors(colors(),
C > 20,
byCols=c("C"),
return_type="df");
plot(colors_df$h, colors_df$H,
xlab="hsv hue h",
ylab="HCL hue H",
pch=20,
cex=colors_df$s * 1 + 1,
col=colors_df$hex);
title("Comparison of HCL hue H\nwith hsv hue h")
plot(colors_df$s, colors_df$C,
xlab="hsv saturation s",
ylab="HCL chroma C",
pch=20,
cex=colors_df$s * 1 + 1,
col=colors_df$hex);
title("Comparison of HCL C\nwith hsv s")
plot(colors_df$v, colors_df$L,
xlab="hsv vibrance v",
ylab="HCL luminance L",
pch=20,
cex=colors_df$s * 1 + 1,
col=colors_df$hex);
title("Comparison of HCL L\nwith hsv v")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.