Automatically select appropriate color scale

which_pal_scale(mapping, palette = "ggplot2", data = NULL,
  fill_type = c("continuous", "discrete"), color_type = c("continuous",
  "discrete"))

Arguments

mapping

Aesthetics used in ggplot.

palette

Color palette

data

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

fill_type

Scale to use according to the variable used in fill : "discrete" or "continuous".

color_type

Scale to use according to the variable used in color : "discrete" or "continuous".

Value

a list

Examples

library(ggplot2) # Automatic guess according to data which_pal_scale( mapping = aes(fill = Sepal.Length), palette = "ggplot2", data = iris )
#> $scales #> [1] "fill_gradient" #> #> $args #> list() #>
which_pal_scale( mapping = aes(fill = Species), palette = "ggplot2", data = iris )
#> $scales #> [1] "fill_hue" #> #> $args #> list() #>
# Explicitly specify type which_pal_scale( mapping = aes(color = variable), palette = "Blues", color_type = "discrete" )
#> $scales #> [1] "color_brewer" #> #> $args #> $args$color_brewer #> $args$color_brewer$palette #> [1] "Blues" #> #> #>
# Both scales which_pal_scale( mapping = aes(color = var1, fill = var2), palette = "Blues", color_type = "discrete", fill_type = "continuous" )
#> $scales #> [1] "fill_distiller" "color_brewer" #> #> $args #> $args$fill_distiller #> $args$fill_distiller$palette #> [1] "Blues" #> #> #> $args$color_brewer #> $args$color_brewer$palette #> [1] "Blues" #> #> #>