layer(geom = NULL, stat = NULL, data = NULL, mapping = NULL, position = NULL, params = list(), inherit.aes = TRUE, subset = NULL, show.legend = NA)
aes
or
aes_
. If specified and inherit.aes = TRUE
(the
default), is combined with the default mapping at the top level of the
plot. You only need to supply mapping
if there isn't a mapping
defined for the plot.geom
and stat
.FALSE
, overrides the default aesthetics,
rather than combining with them. This is most useful for helper functions
that define both data and aesthetics and shouldn't inherit behaviour from
the default plot specification, e.g. borders
.NA
, the default, includes if any aesthetics are mapped.
FALSE
never includes, and TRUE
always includes.Create a new layer
# geom calls are just a short cut for layer ggplot(mpg, aes(displ, hwy)) + geom_point()
# shortcut for ggplot(mpg, aes(displ, hwy)) + layer(geom = "point", stat = "identity", position = "identity")