geom_ribbon {ggplot2} | R Documentation |
Ribbons, y range with continuous x values
geom_ribbon(mapping=NULL, data=NULL, stat="identity", position="identity", ...)
mapping |
mapping between variables and aesthetics generated by aes |
data |
dataset used in this layer, if not specified uses plot dataset |
stat |
statistic used by this layer |
position |
position adjustment used by this layer |
... |
ignored |
This page describes geom_ribbon, see layer
and qplot
for how to create a complete plot from individual components.
A layer
The following aesthetics can be used with geom_ribbon. Aesthetics are mapped to variables in the data with the aes
function: geom\_ribbon(\code{aes}(x = var))
x
: x position (required)
ymin
: minimum of interval (required)
ymax
: maximum of interval (required)
colour
: border colour
fill
: internal colour
size
: size
linetype
: line type
Hadley Wickham, http://had.co.nz/
geom_bar
: Discrete intervals (bars)
geom_linerange
: Discrete intervals (lines)
geom_polygon
: General polygons
## Not run: # 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")) ## End(Not run)