| scale_color_okcolors | R Documentation |
Applies a custom discrete or continuous color scale to ggplot2 plots using a selected palette from the okcolors package.
scale_color_okcolors(palette = "obsession", discrete = TRUE, ...)
palette |
Character. Name of the palette to use. Must be one of the palettes available in 'okcolors()'. Default is '"obsession"'. |
discrete |
Logical. Whether to use a discrete scale ('TRUE') or a continuous scale ('FALSE'). Default is 'TRUE'. |
... |
Additional arguments passed to 'ggplot2::discrete_scale()' or 'ggplot2::scale_color_gradientn()'. |
A 'Scale' object that can be added to a ggplot2 plot.
library(ggplot2)
ggplot2::ggplot(ggplot2::mpg, ggplot2::aes(displ, hwy, color = class)) +
ggplot2::geom_point(size = 3) +
scale_color_okcolors("obsession")
ggplot2::ggplot(ggplot2::mpg, ggplot2::aes(displ, hwy, color = hwy)) +
ggplot2::geom_point(size = 3) +
scale_color_okcolors("skyscrapers", discrete = FALSE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.