autocogs (version 0.1.3)

layer_count: Plot layer count

Description

Retrieves the number of layers in a given plot

Usage

layer_count(p)

# S3 method for default layer_count(p)

# S3 method for ggplot layer_count(p)

Arguments

p

plot object

Value

number

Examples

Run this code
# NOT RUN {
library(ggplot2)
p <- ggplot(iris, aes(Sepal.Length, Sepal.Width)) + geom_point()
layer_count(p) # 1
layer_count(p + geom_smooth(method = "lm") + geom_density_2d()) # 3
# }

Run the code above in your browser using DataCamp Workspace