layer_count: Plot layer count

Description Usage Arguments Value Examples

View source: R/layer_count.R

Description

Retrieves the number of layers in a given plot

Usage

1
2
3
4
5
6
7
layer_count(p)

## Default S3 method:
layer_count(p)

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

Arguments

p

plot object

Value

number

Examples

1
2
3
4
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

autocogs documentation built on May 30, 2021, 1:07 a.m.