Checks if any of the layers of a ggplot contain a specific class.

is_any_layer_class(ggplot, class_nm = "GeomDensity")

Arguments

ggplot

Check the layers of this ggplot object

class_nm

The class name to check, note this differs slightly from the name of the geom function. Defaults to "GeomDensity", checking to see if geom_density was used in any of the layers.

See also

ggplot2::theme for all theme options.

Examples

library(ggplot2)
library(spinifex)

g <- ggplot(mtcars, aes(disp, color = factor(cyl))) + 
  geom_density() + geom_histogram()
is_any_layer_class(g, "GeomDensity")
#> [1] TRUE
is_any_layer_class(g, "GeomPoint")
#> [1] FALSE