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

schloerke/autocog documentation built on June 26, 2018, 3:21 p.m.