Skip to contents

From the data and variable used in aesthetics, decide which geometry can be used and which one is used by default.

Usage

potential_geoms(data, mapping, auto = FALSE)

potential_geoms_ref()

Arguments

data

A data.frame

mapping

List of aesthetic mappings to use with data.

auto

Return only one geometry.

Value

A character vector

Examples


library(ggplot2)

# One continuous variable
potential_geoms(
  data = iris,
  mapping = aes(x = Sepal.Length)
)
#> [1] "histogram" "boxplot"   "violin"    "density"  

# Automatic pick a geom
potential_geoms(
  data = iris,
  mapping = aes(x = Sepal.Length),
  auto = TRUE
)
#> [1] "histogram"

# One discrete variable
potential_geoms(
  data = iris,
  mapping = aes(x = Species)
)
#> [1] "bar"

# Two continuous variables
potential_geoms(
  data = iris,
  mapping = aes(x = Sepal.Length, y = Sepal.Width)
)
#>  [1] "point"  "jitter" "line"   "step"   "path"   "area"   "smooth" "text"  
#>  [9] "label"  "tile"  
# Reference used by esquisse to select available geoms
# and decide which one to use by default
potential_geoms_ref()
#>             x          y      geom auto
#> 1  continuous      empty histogram    1
#> 2  continuous      empty   boxplot    0
#> 3  continuous      empty    violin    0
#> 4  continuous      empty   density    0
#> 5    discrete      empty       bar    1
#> 6        time      empty histogram    1
#> 7        time      empty       bar    0
#> 8  continuous   discrete   boxplot    0
#> 9  continuous   discrete     point    0
#> 10 continuous   discrete    jitter    0
#> 11 continuous   discrete    violin    0
#> 12 continuous   discrete       bar    1
#> 13   discrete continuous       col    1
#> 14   discrete continuous       bar    0
#> 15   discrete continuous   boxplot    0
#> 16   discrete continuous     point    0
#> 17   discrete continuous    jitter    0
#> 18   discrete continuous    violin    0
#> 19   discrete continuous      text    0
#> 20   discrete continuous     label    0
#> 21 continuous continuous     point    1
#> 22 continuous continuous    jitter    0
#> 23 continuous continuous      line    0
#> 24 continuous continuous      step    0
#> 25 continuous continuous      path    0
#> 26 continuous continuous      area    0
#> 27 continuous continuous    smooth    0
#> 28 continuous continuous      text    0
#> 29 continuous continuous     label    0
#> 30   discrete   discrete      tile    1
#> 31       time continuous      line    1
#> 32       time continuous     point    0
#> 33       time continuous      step    0
#> 34       time continuous      area    0
#> 35       time continuous       bar    0
#> 36       time continuous    smooth    0
#> 37      empty continuous      line    1
#> 38      empty continuous      step    0
#> 39      empty continuous      path    0
#> 40      empty continuous      area    0
#> 41 continuous continuous      tile    0
#> 42   discrete       time      tile    0
#> 43       time   discrete      tile    0