Skip to contents

Helper function to extract ggplot layer names from a ggplot object

Usage

get_ggplot_layer_names(fig)

Arguments

fig

A ggplot2 object.

Value

A character vector with all the layer names of the 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"