Helper function to quickly apply a palette to common plotting functions
palette_color(name, n = NULL, reverse = FALSE)A function that can be used with the col parameter in plotting functions
if (FALSE) { # \dontrun{
# For base R plots
plot(mpg ~ disp, data = mtcars, col = palette_color("sunset")(factor(mtcars$cyl)))
# For ggplot2 (after setting up scale_color_palette or scale_fill_palette)
library(ggplot2)
ggplot(mtcars, aes(mpg, disp, color = factor(cyl))) +
geom_point() +
scale_color_manual(values = palette_color("sunset")(3))
} # }