Learn R Programming

avstrat (version 0.1.1)

scale_fill_stratpal: Stratigraphic fill scale

Description

A ggplot2 fill scale that uses one of the built-in stratigraphic palettes.

Usage

scale_fill_stratpal(
  palette = c("stratpal_rpg", "stratpal_grays"),
  overrides = NULL,
  allow_na = FALSE,
  na_color = "gray90",
  ...
)

Value

A ggplot2 scale object.

Arguments

palette

Character string naming which palette to use. Options are names of palettes in .stratpalettes.

overrides

Optional named character vector of colors to override entries in the chosen palette.

allow_na

Logical. If TRUE, missing categories are filled with na_color instead of erroring.

na_color

Color to use for missing categories when allow_na = TRUE.

...

Additional arguments passed to ggplot2::scale_fill_manual().

Examples

Run this code
library(ggplot2)
ggplot(mtcars, aes(factor(cyl), fill = factor(cyl))) +
  geom_bar() +
  scale_fill_stratpal("stratpal_rpg")

# Override one color
scale_fill_stratpal("stratpal_rpg", overrides = c("volcanic" = "orange"))

# Allow missing categories to be filled with gray
scale_fill_stratpal("stratpal_grays", allow_na = TRUE)

Run the code above in your browser using DataLab