Skip to contents

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


black_or_white("red")
#> [1] "white"
black_or_white(colors()[1:10])
#>  [1] "black" "black" "black" "black" "black" "black" "black" "black" "black"
#> [10] "black"