| Title: | Tools for Colors in a Hue-Saturation-Value (HSV) Color Model |
|---|---|
| Description: | R package with handy functions to help users select and play with color schemes in an HSV color model. Compatibility updates by Renova. |
| Authors: | Gaston Sanchez [aut, cre] |
| Maintainer: | Gaston Sanchez <[email protected]> |
| License: | GPL-3 |
| Version: | 0.1.5.9001 |
| Built: | 2026-11-16 18:28:23 UTC |
| Source: | https://github.com/renova-r/colortools |
Adjacent color schemes use colors that are next to each other on the color wheel. These colors usually match well and create comfortable designs.
adjacent(color, plot = TRUE, bg = "white", labcol = NULL, cex = 0.8, title = TRUE)adjacent(color, plot = TRUE, bg = "white", labcol = NULL, cex = 0.8, title = TRUE)
color |
an R color name or a color in hexadecimal notation |
plot |
logical value indicating whether to plot a color wheel with the generated scheme |
bg |
background color of the plot. Used only when
|
labcol |
color for the labels (i.e. names of the
colors). Used only when |
cex |
numeric value indicating the character expansion of the labels |
title |
logical value indicating whether to display
a title in the plot. Used only when |
The analogous colors are obtained following a color wheel with 12 colors, each one spaced at 30 degrees from each other.
A character vector with the given color and the analogous colors in hexadecimal notation
Gaston Sanchez
complementary, splitComp,
triadic, tetradic,
square
# analogous colors of 'red' adjacent("red", plot = FALSE) # analogous colors of 'tomato' with default color wheel analogous("tomato") # analogous colors of '#606FEF' with darker background adjacent("#606FEF", bg = "gray20")# analogous colors of 'red' adjacent("red", plot = FALSE) # analogous colors of 'tomato' with default color wheel analogous("tomato") # analogous colors of '#606FEF' with darker background adjacent("#606FEF", bg = "gray20")
This function returns the anagrams of a given color. Anagrams are made by rearranging the hexadecimal letter pairs to form another color.
anagrams(color)anagrams(color)
color |
an R color name or a color in hexadecimal notation |
An anagram is a word that is made by rearranging the letters of another word. In this case, we have color names instead of words, and hexadecimal letter-pairs instead of single letters. For example, the color "#CD1091" is composed by three pairs "CD", "10", and "91". By rearranging these three pairs, we could obtain an anagram like "#CD9110" or "#10CD91"
A character vector with the anagram colors of a given color in hexadecimal notation
Gaston Sanchez
# anagrams of 'tomato' ana_tom <- anagrams("tomato") # plot tomato anagrams in a color 'pizza' wheel pizza(ana_tom, bg = "gray20")# anagrams of 'tomato' ana_tom <- anagrams("tomato") # plot tomato anagrams in a color 'pizza' wheel pizza(ana_tom, bg = "gray20")
col2HSV converts an R color (or a set of colors) into an HSV color model, and then returns the color names in hexadeciaml notation
col2HSV(color)col2HSV(color)
color |
an R color name or a color in hexadecimal notation |
A character vector with the color(s) name(s) in hexadecimal notation
Gaston Sanchez
# convert 'tomato' col2HSV("tomato")# convert 'tomato' col2HSV("tomato")
Complementary or opposite color scheme is formed by colors that are opposite each other on the color wheel (example: red and green). The high contrast of complementary colors creates a vibrant look that must be managed well so it is not jarring.
complementary(color, plot = TRUE, bg = "white", labcol = NULL, cex = 0.8, title = TRUE)complementary(color, plot = TRUE, bg = "white", labcol = NULL, cex = 0.8, title = TRUE)
color |
an R color name or color in hexadecimal notation |
plot |
logical value indicating whether to plot a color wheel with the generated scheme |
bg |
background color of the plot. Used only when
|
labcol |
color for the labels (i.e. names of the
colors). Used only when |
cex |
numeric value indicating the character expansion of the labels |
title |
logical value indicating whether to display
a title in the plot. Used ony when |
The complementary color is obtained following a color wheel with 12 colors, each one spaced at 30 degrees from each other. Complementary color schemes are tricky to use in large doses, but work well when you wnat something to stand out. In addition, omplementary colors are really bad for text.
A character vector with the given color and the complementary color in hexadecimal notation
Gaston Sanchez
adjacent, splitComp,
triadic, tetradic,
square
# complementary color of 'tomato' with no plot opposite("tomato", plot = FALSE) # complementary color of 'tomato' with color wheel opposite("tomato", bg = "gray30")# complementary color of 'tomato' with no plot opposite("tomato", plot = FALSE) # complementary color of 'tomato' with color wheel opposite("tomato", bg = "gray30")
This function can be used to display the palettes included in the package, or to show the color names of the specified palette
pals(name = NULL, bg = "white")pals(name = NULL, bg = "white")
name |
optional argument to specify the name of the palette |
bg |
background color of the plot. Used only when
|
When no name is given, a plot window will show the different palettes. If a name is given, then the function will return the names of the colors for that palette (no plot)
Gaston Sanchez
# default use pals() # color names of palette 'terra' pals("terra") # pizza wheel for palette 'cheer' pizza(pals("cheer"), init.angle = 90) # color wheel for first color in palette 'fish' wheel(pals("fish")[1])# default use pals() # color names of palette 'terra' pals("terra") # pizza wheel for palette 'cheer' pizza(pals("cheer"), init.angle = 90) # color wheel for first color in palette 'fish' wheel(pals("fish")[1])
This function displays a color wheel with specified colors
pizza(colors, bg = "gray95", border = NA, init.angle = 105, cex = 0.8, lty = 1, labcol = NULL, ...)pizza(colors, bg = "gray95", border = NA, init.angle = 105, cex = 0.8, lty = 1, labcol = NULL, ...)
colors |
a vector with R color names of colors in hexadecimal notation |
bg |
background color of the plot. Default
|
border |
color of the border separating the pizza slices |
init.angle |
integer value indicating the start angle (in degrees) for the slices |
cex |
numeric value indicating the character expansion of the labels |
lty |
argument passed to |
labcol |
color for the labels (i.e. names of the colors) |
... |
graphical parameters ( |
This function is based on the pie function
Gaston Sanchez
# pizza color wheel for rainbow colors pizza(rainbow(7)) # pizza color wheel for tomato (18 colors) pizza(setColors("tomato", 18), bg = "gray20", cex = 0.7)# pizza color wheel for rainbow colors pizza(rainbow(7)) # pizza color wheel for tomato (18 colors) pizza(setColors("tomato", 18), bg = "gray20", cex = 0.7)
This functions allows to get a sequence of colors in an HSV model with optional pre-especified numbers for saturation, value, and alpha. It is a very flexible function to play with different combinations of saturation, value, and alpha.
sequential(color, percentage = 5, what = "saturation", s = NULL, v = NULL, alpha = NULL, fun = "linear", plot = TRUE, verbose = TRUE)sequential(color, percentage = 5, what = "saturation", s = NULL, v = NULL, alpha = NULL, fun = "linear", plot = TRUE, verbose = TRUE)
color |
an R color name or a color in hexadeciaml notation |
percentage |
numeric value indicating the increment steps of the sequence in percentage |
what |
character string indicating what parameter to
taki into account to generate the sequence. Possible
values are |
s |
optional decimal value (between 0 and 1) to fix the color saturation |
v |
optional decimal value (between 0 and 1) to fix the color value |
alpha |
optional decimal value (between 0 and 1) to fix the color alpha transparency |
fun |
character string indicating the applied
transformation to the generated sequence. Possible values
are |
plot |
logical value indicating whether to plot the sequence |
verbose |
logical value indicating whether to return the color names of the sequence |
The idea bechind this function is to explore a sequence
of colors given some fixed numbers of saturation, valur
or alpha for an HSV color model. The argument what
will be taken to generate the sequence in the given
percentage increment steps. In addition, we can
specify a number for s, v, alpha. For example, if
what="value", we can fix the saturation in
s=0.8, obtaining a sequence of colors with
different values but with the same level of saturation.
The argument fun allows to apply a transformation
to the generated sequence. By default
fun="linear", no transformation is applied. If
fun="sqrt", the square root of the generated
sequence will be taken. If fun="log", the
logarithmic of the generated sequence will be taken.
Gaston Sanchez
# sequence for 'orange' sequential("orange") # sequence for 'orange' with fun='sqrt' transformation sequential("orange", fun = "sqrt") # sequence for 'orange' with fun='log' transformation sequential("orange", fun = "log") # sequential sequence for value with fix saturation s=0.7 and fun='log' sequential("orange", what = "value", s = 0.7, fun = "log") # sequential sequence for saturation, with fix value s=0.8, alpha=0.5, percentage 10, and fun='log' sequential("orange", 10, what = "value", s = 0.7, alpha = 0.5, fun = "log")# sequence for 'orange' sequential("orange") # sequence for 'orange' with fun='sqrt' transformation sequential("orange", fun = "sqrt") # sequence for 'orange' with fun='log' transformation sequential("orange", fun = "log") # sequential sequence for value with fix saturation s=0.7 and fun='log' sequential("orange", what = "value", s = 0.7, fun = "log") # sequential sequence for saturation, with fix value s=0.8, alpha=0.5, percentage 10, and fun='log' sequential("orange", 10, what = "value", s = 0.7, alpha = 0.5, fun = "log")
This function set a given number of colors to create a color wheel
setColors(color, num)setColors(color, num)
color |
an R color name or a color in hexadecimal notation |
num |
integer value indicating how many colors to be added to the wheel |
A character vector with the given color and the set of colors to create a wheel color
Gaston Sanchez
# create a color wheel based on 'tomato' setColors("tomato", 12) # set 7 colors for '#3D6DCC' setColors("#3D6DCC", 7)# create a color wheel based on 'tomato' setColors("tomato", 12) # set 7 colors for '#3D6DCC' setColors("#3D6DCC", 7)
The split-complementary color scheme is a variation of the complementary color scheme. It uses the two colors adjacent to its complement.
splitComp(color, plot = TRUE, bg = "white", labcol = NULL, cex = 0.8, title = TRUE)splitComp(color, plot = TRUE, bg = "white", labcol = NULL, cex = 0.8, title = TRUE)
color |
an R color name of a color in hexadecimal notation |
plot |
logical value indicating whether to plot a color wheel with the generated scheme |
bg |
background color of the plot. Used only when
|
labcol |
color for the labels (i.e. names of the
colors). Used only when |
cex |
numeric value indicating the character expansion of the labels |
title |
logical value indicating whether to display
a title in the plot. Unsed only when |
This color scheme has the same strong visual contrast as the complementary scheme, but it is supposed to have less tension.
A character vector with the given color and the split-complementary colors in hexadecimal notation
Gaston Sanchez
# split-complementary colors of 'tomato' (no plot) splitComp("tomato", plot = FALSE) # split-complementary colors of 'tomato' (with dark gray background) splitComp("tomato", bg = "gray40")# split-complementary colors of 'tomato' (no plot) splitComp("tomato", plot = FALSE) # split-complementary colors of 'tomato' (with dark gray background) splitComp("tomato", bg = "gray40")
The square color scheme is similar to the tetradic scheme, but with all four colors spaced around the color circle.
square(color, plot = TRUE, bg = "white", labcol = NULL, cex = 0.8, title = TRUE)square(color, plot = TRUE, bg = "white", labcol = NULL, cex = 0.8, title = TRUE)
color |
an R color name or a color in hexadecimal notation |
plot |
logical value indicating whether to plot a color wheel with the generated scheme |
bg |
background color of the plot. Used only when
|
labcol |
color for the labels (i.e. names of the
colors). Used only when |
cex |
numeric value indicating the character expansion of the labels |
title |
logical value indicating whether to display
a title in the plot. Used only when |
The square colors are obtained following a color wheel with 12 colors, each one spaced at 30 degrees from each other. Square color schemes tend to work best if you let one color be dominant
A character vector with the given color and the square scheme colors in hexadecimal notation
Gaston Sanchez
complementary, adjacent,
triadic, tetradic
# square color scheme for 'tomato' square("tomato")# square color scheme for 'tomato' square("tomato")
Tetradic color schemes uses four colors arranged into two complementary pairs.
tetradic(color, plot = TRUE, bg = "white", labcol = NULL, cex = 0.8, title = TRUE)tetradic(color, plot = TRUE, bg = "white", labcol = NULL, cex = 0.8, title = TRUE)
color |
an R color name or a color in hexadecimal notation |
plot |
logical value indicating whether to plot a color wheel with the generated scheme |
bg |
background color of the plot. Used only when
|
labcol |
color for the labels (i.e. names of the
colors). Used only when |
cex |
numeric value indicating the character expansion of the labels |
title |
logical value indicating whether to display
a title in the plot. Used only when |
The tetradic colors are obtained following a color wheel with 12 colors, each one spaced at 30 degrees from each oter.
A character vector with the given color and the tetradic colors in hexadecimal notation
Gaston Sanchez
complementary, splitComp,
adjacent, triadic,
square
# tetradic colors for 'tomato' tetradic("tomato") # tetradic colors for 'tomato' with bg='gray20' tetradic("tomato", bg = "gray20")# tetradic colors for 'tomato' tetradic("tomato") # tetradic colors for 'tomato' with bg='gray20' tetradic("tomato", bg = "gray20")
Triadic color schemes use colors that are evenly spaced around the color wheel.
triadic(color, plot = TRUE, bg = "white", labcol = NULL, cex = 0.8, title = TRUE)triadic(color, plot = TRUE, bg = "white", labcol = NULL, cex = 0.8, title = TRUE)
color |
an R color name or a color in hexadecimal notation |
plot |
logical value indicating whether to plot a color wheel with the generated scheme |
bg |
background color of the plot. Used only when
|
labcol |
color for the labels (i.e. names of the
colors). Used only when |
cex |
numeric value indicating the character expansion of the labels |
title |
logical value indicating whether to display
a title in the plot. Used only when |
The triadic colors are obtained following a color wheel with 12 colors, each one spaced at 30 degrees from each other. Triadic color schemes tend to be quite vibrant. To use a triadic harmony successfully, the colors should be carefully balanced letting one color dominate and use the others for accent.
A character vector with the given color and the triadic colors in hexadecimal notation
Gaston Sanchez
complementary, splitComp,
adjacent, tetradic,
square
# triadic colors of 'tomato' triadic("tomato") # triadic colors of 'tomato' with background color 'gray20' triadic("tomato", bg = "gray20")# triadic colors of 'tomato' triadic("tomato") # triadic colors of 'tomato' with background color 'gray20' triadic("tomato", bg = "gray20")
This function generates a color wheel for a given color
wheel(color, num = 12, bg = "gray95", border = NULL, init.angle = 105, cex = 1, lty = NULL, main = NULL, verbose = TRUE, ...)wheel(color, num = 12, bg = "gray95", border = NULL, init.angle = 105, cex = 1, lty = NULL, main = NULL, verbose = TRUE, ...)
color |
an R color name or a color in hexadecimal notation |
num |
integer value indicating how many colors to be generated for the color wheel |
bg |
background color of the plor |
border |
color of the border separating the slices |
init.angle |
integer value indicating the start angle (in degrees) for the slices |
cex |
numeric value indicating the character expansion of the labels |
lty |
argument passed to |
main |
an overall title for the plot |
verbose |
logical value indicating whether to return the color names |
... |
graphical parameters ( |
This function is based on the pie function
A character vector with the color names of the generated wheel in hexadecimal notation
Gaston Sanchez
# wheel color with 18 slices for 'tomato' wheel("tomato", num = 18, bg = "gray20", cex = 0.7)# wheel color with 18 slices for 'tomato' wheel("tomato", num = 18, bg = "gray20", cex = 0.7)