Skip to contents

Apply the tidyMacro color palette to the color aesthetic in ggplot2 plots. This scale is particularly useful for line plots, impulse response functions, and other visualizations where multiple series need distinct colors.

Usage

scale_color_tidyMacro(
  palette = tidyMacro_colors,
  discrete = TRUE,
  reverse = FALSE,
  ...
)

scale_colour_tidyMacro(
  palette = tidyMacro_colors,
  discrete = TRUE,
  reverse = FALSE,
  ...
)

Arguments

palette

Character vector of hex colors. Default is tidyMacro_colors.

discrete

Logical. If TRUE (default), creates a discrete scale.

reverse

Logical. If TRUE, reverses the order of colors. Default is FALSE.

...

Additional arguments passed to discrete_scale.

Value

A ggplot2 color scale that can be added to a plot.

Details

This function creates a discrete color scale using the tidyMacro palette. If the number of groups exceeds the 14 available colors, the palette will be recycled with a warning.

Examples

if (FALSE) { # \dontrun{
library(ggplot2)
library(tidyMacro)

# IRF plot with multiple variables
ggplot(irf_data, aes(x = horizon, y = response, color = variable)) +
  geom_line(linewidth = 1) +
  geom_hline(yintercept = 0, linetype = "dashed", color = "gray50") +
  labs(title = "Impulse Response Functions",
       x = "Horizon",
       y = "Response") +
  scale_color_tidyMacro() +
  ftheme_tidyMacro()

# Reverse color order
ggplot(fevd_data, aes(x = horizon, y = share, color = shock)) +
  geom_line(linewidth = 1) +
  scale_color_tidyMacro(reverse = TRUE) +
  ftheme_tidyMacro()
} # }