ggspectra (version 0.3.1)

black_or_white: Chose black vs. white color based on weighted mean of RGB channels

Description

Chose black or white color based on a color to be used as background. Usefull when using geom_text on top of tiles or bars, or geom_label with a variable fill.

Usage

black_or_white(colors, threshold = 0.45)

Arguments

colors

character A vector of color definitions.

threshold

numeric in range 0 to 1.

Examples

Run this code
# NOT RUN {
black_or_white("red")
black_or_white(colors()[1:10])

# }

Run the code above in your browser using DataCamp Workspace