Maps groups to colors using selected colors or a default palette. Handles named color vectors by matching to group names, fills in missing colors with fallback values, and ensures the output vector is named and matches group length.
Arguments
- groups
A character vector of group names to assign colors to.
- selected_colors
A named or unnamed character vector of colors to use. If named, colors are matched to groups by name. If NULL or empty, uses
default_palette.- default_palette
A character vector of fallback colors to use when
selected_colorsis NULL/empty or when groups have missing colors. Defaults to "#000000" (black) if not provided.
Value
A named character vector of colors with names corresponding to groups, or NULL if groups is empty.