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
typeis"seq"or"div", the function will return a discrete color spectrum withncolorsIf the value is an integer number and
typeis"qual", the function will returnncolors from thecolorsparameter, repeating them if necessaryIf the value is a
numericvector between0and1, the function will return the color positions atnconsidering a continuous color spectrum ranging from0to1
- alpha
(Optional) A number between
0and1, indicating the transparency of the colors (Default:NULL).- direction
(Optional) A number (
1or-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
