layer_count {autocogs}R Documentation

Plot layer count

Description

Retrieves the number of layers in a given plot

Usage

layer_count(p)

## Default S3 method:
layer_count(p)

## S3 method for class 'ggplot'
layer_count(p)

Arguments

p

plot object

Value

number

Examples

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

[Package autocogs version 0.1.4 Index]