Apply the tidyMacro color palette to the fill aesthetic in ggplot2 plots. This scale is particularly useful for bar charts, area plots, and confidence bands in impulse response visualizations.
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.
Details
This function creates a discrete fill 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)
# FEVD stacked area plot
ggplot(fevd_data, aes(x = horizon, y = contribution, fill = shock)) +
geom_area(position = "stack", alpha = 0.8) +
labs(title = "Forecast Error Variance Decomposition",
x = "Horizon",
y = "Share of Variance") +
scale_fill_tidyMacro() +
ftheme_tidyMacro()
# Bar chart with tidyMacro colors
ggplot(var_summary, aes(x = variable, y = coefficient, fill = lag)) +
geom_col(position = "dodge") +
scale_fill_tidyMacro(reverse = TRUE) +
ftheme_tidyMacro()
} # }
