Helper function to extract ggplot layer names from a ggplot object
Examples
library(ggplot2)
fig <- ggplot(mtcars, aes(x = cyl, y = mpg, group = cyl)) + geom_boxplot() + geom_point()
get_ggplot_layer_names(fig)
#> [1] "geom_boxplot" "geom_point"
Helper function to extract ggplot layer names from a ggplot object
library(ggplot2)
fig <- ggplot(mtcars, aes(x = cyl, y = mpg, group = cyl)) + geom_boxplot() + geom_point()
get_ggplot_layer_names(fig)
#> [1] "geom_boxplot" "geom_point"