You can use cols4all palettes directly in ggplot2 using specialized scale functions.
Discrete Categorical Scales
Use scale_color_discrete_c4a_cat() or scale_fill_discrete_c4a_cat() for qualitative palettes.
library(ggplot2)
library(cols4all)
# Example: using a carto palette for discrete colors
ggplot(data, aes(x = x_var, y = y_var, color = category_var)) +
geom_point() +
scale_color_discrete_c4a_cat("carto.safe")
Continuous Diverging Scales
Use scale_color_continuous_c4a_div() or scale_fill_continuous_c4a_div() for diverging palettes. You can specify a mid value to define the center of the divergence.
# Example: using a wes palette for continuous colors
ggplot(data, aes(x = x_var, y = y_var, color = continuous_var)) +
geom_point() +
scale_color_continuous_c4a_div("wes.zissou1", mid = mean(data$continuous_var))
ggplot(diam_exp, aes(x = carat, y = price, color = color)) +
geom_point(size = 2) +
scale_color_discrete_c4a_cat("carto.safe") +
theme_light()