remove_geomR Documentation

Remove a layer from a compiled ggplot2 object.

Description

Removes specified layers from a ggplot object.

Usage

remove_geom(p, geom, idx = NULL)

Arguments

p

ggplot2 plot object

geom

character string of the name of the layer to remove

idx

numeric of which index of geom to remove, Default: 1

Examples

p <- ggplot2::ggplot(iris,ggplot2::aes(x =Sepal.Length,y=Sepal.Width))
p <- p+ggplot2::geom_point(ggplot2::aes(colour=Species))+ggplot2::geom_line()
p
pnew <- p%>%remove_geom('point',1)
pnew