---
title: "highlight_colors"
---

[< Back to Reference](../reference.qmd) | [View source](https://codeberg.org/usrbinr/stwd/src/branch/main/R/colors.R#L115)

# `highlight_colors()`

Create a Highlight Color Palette

## Usage

```r
highlight_colors(
  categories,
  highlight,
  highlight_color = "#1E90FF",
  gray_color = "#D3D3D3"
)
```

## Arguments

| Argument | Description |
|----------|-------------|
| `categories` | Character vector of all category names. |
| `highlight` | Character vector of categories to highlight, or a named vector where names are categories and values are their highlight colors. |
| `highlight_color` | Color for highlighted categories (used when `highlight` is unnamed). Default: "#1E90FF" (dodger blue). |
| `gray_color` | Color for non-highlighted categories. Default: light gray. |

## Value

A named vector of colors.

## Description

Creates a color vector where only specified categories are highlighted
and all others are grayed out.

## Details

Follows the Storytelling with Data principle of using color strategically
for emphasis. By graying out non-essential categories, the viewer's
attention is drawn to the highlighted data points. Use with
`scale_fill_manual()` or `scale_color_manual()`.

## Examples

```r
categories <- c("A", "B", "C", "D", "E")

# Highlight one category
highlight_colors(categories, "C")

# Highlight multiple with custom colors
highlight_colors(categories, c("A" = "#E63946", "C" = "#2A9D8F"))
```

