set_palette: Sets the default ggplot2 palettes

View source: R/palettes.R

set_paletteR Documentation

Sets the default ggplot2 palettes

Description

This function sets the global ggplot2 options for discrete (ggplot2.discrete.fill and ggplot2.discrete.colour) and continuous (ggplot2.continuous.fill and ggplot2.continuous.colour) palettes to specified palettes from the dunnr package. Use help(scale_colour_discrete) to see how these options work.

Usage

set_palette(discrete_pal = "pastel6", continuous_pal = "div5")

Arguments

discrete_pal

One of the palettes from td_pal().

continuous_pal

One of the palettes from td_pal().

Examples

# Sets pastel6 for discrete and div5 for continuous as the default palettes
set_palette()

library(ggplot2)
library(dplyr)

p <- diamonds %>%
  filter(carat >= 2.2) %>%
  ggplot(aes(x = price, y = cut, fill = cut)) +
  geom_boxplot() +
  theme(legend.position = "none")
p

p <- faithfuld %>%
  ggplot(aes(waiting, eruptions, fill = density)) +
  geom_tile() +
  scale_x_continuous(expand = c(0, 0)) +
  scale_y_continuous(expand = c(0, 0))
p

taylordunn/dunnr documentation built on Aug. 8, 2022, 12:28 p.m.