scale-palettehex: Colour scales for ggplot2

scale-palettehexR Documentation

Colour scales for ggplot2

Description

Colour and fill scales for ggplot2 plots, using object of class palettehex.

Usage

scale_colour_palettehex_d(x, which = 1, reverse = FALSE, ...)

scale_color_palettehex_d(x, which = 1, reverse = FALSE, ...)

scale_fill_palettehex_d(x, which = 1, reverse = FALSE, ...)

scale_colour_palettehex_c(x, which = 1, reverse = FALSE, ...)

scale_color_palettehex_c(x, which = 1, reverse = FALSE, ...)

scale_fill_palettehex_c(x, which = 1, reverse = FALSE, ...)

Arguments

x

object of class palettehex

which

selection of which palette of a set to choose. Either by name, id or numeric index.

reverse

logical. If scale should b reversed (default: FALSE)

...

arguments to be passed to discrete_scale

Details

The palettehex class is a data.frame of many palettes. This function takes such a data.frame and a choice of palette by name, id or numeric index can be made for the scale.

Value

ggplot2-proto

Functions

  • scale_colour_palettehex_d(): Discrete colour scale

  • scale_color_palettehex_d(): Discrete colour scale

  • scale_fill_palettehex_d(): Discrete fill scale

  • scale_colour_palettehex_c(): Continuous colour scale

  • scale_color_palettehex_c(): Continuous colour scale

  • scale_fill_palettehex_c(): Continuous fill scale

Examples

if(curl::has_internet()){
library(ggplot2)

x <- get_popular_palettes()

ggplot(mtcars, aes(mpg)) +
   geom_density(aes(fill = disp, group = disp)) +
   scale_fill_palettehex_c(x)

ggplot(mtcars, aes(mpg)) +
  geom_density(aes(fill = disp, group = disp)) +
  scale_fill_palettehex_c(x, 3)

ggplot(mtcars, aes(mpg, disp, colour = factor(cyl))) +
   geom_point() +
   scale_color_palettehex_d(x)

ggplot(mtcars, aes(mpg, disp, colour = factor(cyl))) +
   geom_point() +
   scale_color_palettehex_d(x, 1872)
}

colorhex documentation built on Sept. 11, 2023, 9:06 a.m.