Skip to contents

This function intelligently applies manual or automatically generated color/fill scales based on the number of unique levels in the specified variable and the available custom colors. If the variable is continuous, it defaults to a viridis scale.

Usage

generate_color_scale(data, var_name, current_colors, type = c("color", "fill"))

Arguments

data

A data frame containing the variable.

var_name

A string specifying the column name for color or fill mapping.

current_colors

A vector of preferred colors from the style settings.

type

The type of scale to generate: "color" or "fill".

Value

A ggplot2 scale object (e.g., `scale_color_manual`, `scale_fill_manual`) or NULL if no variable to map.