which_pal_scale: Automatically select appropriate color scale

Description Usage Arguments Value Examples

View source: R/scales.R

Description

Automatically select appropriate color scale

Usage

1
2
3
4
5
6
7
8
which_pal_scale(
  mapping,
  palette = "ggplot2",
  data = NULL,
  fill_type = c("continuous", "discrete"),
  color_type = c("continuous", "discrete"),
  reverse = FALSE
)

Arguments

mapping

Aesthetics used in ggplot.

palette

Color palette.

data

An optional data.frame to choose the right type for variables.

fill_type, color_type

Scale to use according to the variable used in fill/color aesthetic : "discrete" or "continuous". Ignored if data is provided: it will be guessed from data.

reverse

Reverse colors order or not.

Value

a list

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
library(ggplot2)

# Automatic guess according to data
which_pal_scale(
  mapping = aes(fill = Sepal.Length), 
  palette = "ggplot2", 
  data = iris
)
which_pal_scale(
  mapping = aes(fill = Species),
  palette = "ggplot2", 
  data = iris
)


# Explicitly specify type
which_pal_scale(
  mapping = aes(color = variable), 
  palette = "Blues", 
  color_type = "discrete"
)


# Both scales
which_pal_scale(
  mapping = aes(color = var1, fill = var2), 
  palette = "Blues", 
  color_type = "discrete",
  fill_type = "continuous"
)

singha53/esquisse documentation built on Dec. 23, 2021, 2:29 a.m.