color_brand_*
functions are wrappers of
interpolate_colors()
for sequential, diverging,
and qualitative brand color palettes. They serve as facilitators for
getting the colors being used in each brand scale.
Usage
color_brand_sequential(n, alpha = NULL, direction = 1)
color_brand_diverging(n, alpha = NULL, direction = 1)
color_brand_qualitative(n, alpha = NULL, direction = 1)
Arguments
- n
This parameter accepts two types of inputs:
If the value is an integer number and
type
is"seq"
or"div"
, the function will return a discrete color spectrum withn
colorsIf the value is an integer number and
type
is"qual"
, the function will returnn
colors from thecolors
parameter, repeating them if necessaryIf the value is a
numeric
vector between0
and1
, the function will return the color positions atn
considering a continuous color spectrum ranging from0
to1
- alpha
(Optional) A number between
0
and1
, indicating the transparency of the colors (Default:NULL
).- direction
(Optional) A number (
1
or-1
) indicating the direction of the colors. If1
, the order remains the same. If-1
, the order is reversed. (Default:1
).
Value
A character
vector with
hexadecimal color codes.
Details
Path to _brand.yml
brandr
will always look for a _brand.yml
file in the root directory of
your project. If the file is not found, an error message will be displayed.
You can also set the path to the file manually using the
options()
function:
options(BRANDR_BRAND_YML = "PATH_TO_BRAND.YML")
Brand Color Scales
To control the colors for each brand color scale, assign the desired
hexadecimal color codes in a
character
vector to the following options:
BRANDR_COLOR_SEQUENTIAL
: For sequential color scalesBRANDR_COLOR_DIVERGING
: For diverging color scalesBRANDR_COLOR_QUALITATIVE
: For qualitative color scales
You can use get_brand_color()
to get the hexadecimal
color codes from the _brand.yml
file.
Example:
options(
BRANDR_COLOR_SEQUENTIAL =
get_brand_color(c("primary", "secondary")),
BRANDR_COLOR_DIVERGING =
get_brand_color(c("primary", "white", "secondary")),
BRANDR_COLOR_QUALITATIVE =
get_brand_color(c("primary", "secondary", "tertiary"))
)
See also
Other color functions:
interpolate_colors()
Examples
color_brand_sequential(5)
#> [1] "#390963" "#892B4F" "#DA4E3C" "#EA7220" "#FB9706"
#> [1] "#390963" "#892B4F" "#DA4E3C" "#EA7220" "#FB9706" # Expected
color_brand_diverging(5)
#> [1] "#390963" "#9C84B1" "#FFFFFF" "#FDCB82" "#FB9706"
#> [1] "#390963" "#9C84B1" "#FFFFFF" "#FDCB82" "#FB9706" # Expected
color_brand_qualitative(5)
#> [1] "#DA4E3C" "#390963" "#FB9706" "#DA4E3C" "#390963"
#> [1] "#DA4E3C" "#390963" "#FB9706" "#DA4E3C" "#390963" # Expected
color_brand_qualitative(3, alpha = 0.5)
#> [1] "#DA4E3C80" "#39096380" "#FB970680"
#> [1] "#DA4E3C80" "#39096380" "#FB970680" # Expected