Learn R Programming

okcolors (version 0.1.0)

scale_fill_okcolors: Custom ggplot2 Fill Scale using okcolors Palettes

Description

Applies a custom discrete or continuous fill scale to ggplot2 plots using a selected palette from the okcolors package.

Usage

scale_fill_okcolors(palette = "obsession", discrete = TRUE, ...)

Value

A `Scale` object that can be added to a ggplot2 plot.

Arguments

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_fill_gradientn()`.

Examples

Run this code
ggplot2::ggplot(ggplot2::mpg, ggplot2::aes(class, fill = class)) +
  ggplot2::geom_bar() +
  scale_fill_okcolors("skyscrapers")

ggplot2::ggplot(ggplot2::mpg, ggplot2::aes(displ, hwy, fill = hwy)) +
  ggplot2::geom_tile() +
  scale_fill_okcolors("obsession", discrete = FALSE)

Run the code above in your browser using DataLab