geom_ribbongeom_ribbon(mapping=NULL, data=NULL, stat="identity", position="identity", na.rm=FALSE, ...)
Ribbons, y range with continuous x values
This page describes geom_ribbon, see layer and qplot for how to create a complete plot from individual components.
What do you think of the documentation? Please let me know by filling out this short online survey.
The following aesthetics can be used with geom_ribbon. Aesthetics are mapped to variables in the data with the aes function: geom_ribbon(aes(x = var)). Note that you do not need quotes around the variable name.
Scales control how the variable is mapped to the aesthetic and are listed after each aesthetic.
| Aesthetic | Default | Related scales |
|---|---|---|
| x | required | continuous, date, datetime, discrete |
| ymin | required | |
| ymax | required | |
| colour | NA | brewer, gradient, gradient2, gradientn, grey, hue, identity, manual |
| fill | grey20 | brewer, gradient, gradient2, gradientn, grey, hue, identity, manual |
| size | 0.5 | identity, manual, size |
| linetype | 1 | identity, linetype, manual |
| alpha | 1 |
Layers are divided into groups by the group aesthetic. By default this is set to the interaction of all categorical variables present in the plot.
Parameters control the appearance of the geom. In addition to the parameters listed below (if any), any aesthetic can be used as a parameter, in which case it will override any aesthetic mapping.
na.rm: NULLThis function returns a layer object.
> # Generate data > huron <- data.frame(year = 1875:1972, level = as.vector(LakeHuron)) > huron$decade <- round_any(huron$year, 10, floor) > > h <- ggplot(huron, aes(x=year)) > > h + geom_ribbon(aes(ymin=0, ymax=level))> h + geom_area(aes(y = level))
> > # Add aesthetic mappings > h + geom_ribbon(aes(ymin=level-1, ymax=level+1))
> h + geom_ribbon(aes(ymin=level-1, ymax=level+1)) + geom_line(aes(y=level))
> > # Another data set, with multiple y's for each x > m <- ggplot(movies, aes(y=votes, x=year)) > (m <- m + geom_point())
> > # The default summary isn't that useful > m + stat_summary(geom="ribbon", fun.ymin="min", fun.ymax="max")
> m + stat_summary(geom="ribbon", fun.data="median_hilow")
> > # Use qplot instead > qplot(year, level, data=huron, geom=c("area", "line"))
![]()
What do you think of the documentation? Please let me know by filling out this short online survey.