Skip to contents

Generates distinct and visually distinct colours for a set of input tags using the default hue-based palette from ggplot2 (via scales::hue_pal()). This is useful for assigning consistent colours to categorical labels in plots, for example in an animation, where not all individuals always have data in each frame.

Usage

atl_tag_cols(tags, option = "vector")

Arguments

tags

A character or numeric vector of tags. Duplicate values are ignored.

option

A string indicating the output format. Either "vector" for a named character vector of hex colors, or "table" for a data.table with columns tag and colour. Default is "vector".

Value

A named character vector of hex color codes if option = "vector", or a data.table with two columns (tag, colour) if option = "table".

Examples

# Default output (named vector)
atl_tag_cols(c("1234", "2121", "9999"))
#> Error in atl_tag_cols(c("1234", "2121", "9999")): could not find function "atl_tag_cols"

# Output as a data.table
atl_tag_cols(c("1234", "2121", "9999"), option = "table")
#> Error in atl_tag_cols(c("1234", "2121", "9999"), option = "table"): could not find function "atl_tag_cols"