Checks if any of the layers of a ggplot contain a specific class.
is_any_layer_class(ggplot, class_nm = "GeomDensity")
Check the layers of this ggplot object
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.
ggplot2::theme
for all theme options.
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