set_gnomer_palette: Set gnomeR color palette

View source: R/gnomer-color-palette.R

set_gnomer_paletteR Documentation

Set gnomeR color palette

Description

This function sets the gnomeR color palette as the default palette for all ggplot2 objects. It does so by overriding the following four functions from the ggplot2 package: scale_color_discrete(), scale_fill_discrete(), scale_color_continuous(), and scale_fill_continuous(), and places them in the specified environment. A typical workflow would include this function at the top of a script, and subsequent calls to ggplot() will utilize the gnomeR color palette.

Usage

set_gnomer_palette(
  palette = c("pancan", "main", "sunset"),
  gradient = c("pancan", "main", "sunset"),
  reverse = FALSE,
  env = rlang::caller_env()
)

Arguments

palette

name of palette in gnomer_palettes, supplied in quotes. Options include ⁠"pancan", "main", "sunset"⁠. Default is "pancan".

gradient

name of gradient palette in gnomer_palettes, supplied in quotes. Options include ⁠"pancan", "main", "sunset"⁠. Default is "pancan".

reverse

if set to TRUE, will reverse the order of the color palette

env

environment in which palette will take effect. Default is rlang::caller_env().

Author(s)

Michael Curry

Examples

library(ggplot2)

set_gnomer_palette()

ggplot(mtcars, aes(wt, mpg, color = factor(cyl))) +
  geom_point()

# setting other gnomeR palettes
set_gnomer_palette(palette = "main", gradient = "sunset")

ggplot(mtcars, aes(wt, mpg, color = factor(cyl))) +
  geom_point()

ggplot(mtcars, aes(wt, mpg, color = cyl)) +
  geom_point()

AxelitoMartin/gnomeR documentation built on Oct. 18, 2024, 11:39 a.m.