\name{areaplot} \alias{areaplot} \alias{areaplot.default} \alias{areaplot.formula} \title{Area Plots} \description{ Produce a stacked area plot, or add polygons to an existing plot. } \usage{ areaplot(x, \dots) \method{areaplot}{default}(x, y = NULL, prop = FALSE, add = FALSE, xlab = NULL, ylab = NULL, col = NULL, \dots) \method{areaplot}{formula}(formula, data, subset, na.action = NULL, \dots) } \arguments{ \item{x}{numeric vector of x values, or if \code{y=NULL} a numeric vector of y values. Can also be a 1-dimensional table (x values in names, y values in array), matrix or 2-dimensional table (x values in row names and y values in columns), a data frame (x values in first column and y values in subsequent columns), or a time-series object of class \code{ts/mts}.} \item{y}{numeric vector of y values, or a matrix containing y values in columns.} \item{prop}{whether data should be plotted as proportions, so stacked areas equal 1.} \item{add}{whether polygons should be added to an existing plot.} \item{xlab}{label for x axis.} \item{ylab}{label for y axis.} \item{col}{fill color of polygon(s). The default is a vector of gray colors.} \item{formula}{a \code{\link{formula}}, such as \code{y ~ x} or \code{cbind(y1, y2) ~ x}, specifying x and y values. A dot on the left-hand side, \code{formula = . ~ x}, means all variables except the one specified on the right-hand side.} \item{data}{a data frame (or list) from which the variables in \code{formula} should be taken.} \item{subset}{an optional vector specifying a subset of observations to be used.} \item{na.action}{a function which indicates what should happen when the data contain \code{NA} values. The default is to ignore missing values in the given variables.} \item{\dots}{further arguments passed to \code{matplot} and \code{polygon}.} } \value{ Matrix of cumulative sums that was used for plotting. } \author{ Arni Magnusson. } \seealso{ \code{\link{barplot}}, \code{\link{polygon}}. } \examples{ areaplot(rpois(10,40)) areaplot(rnorm(10)) # formula areaplot(Armed.Forces~Year, data=longley) areaplot(cbind(Armed.Forces,Unemployed)~Year, data=longley) # add=TRUE plot(1940:1970, 500*runif(31), ylim=c(0,500)) areaplot(Armed.Forces~Year, data=longley, add=TRUE) # matrix areaplot(WorldPhones) areaplot(WorldPhones, prop=TRUE) # table require(MASS) areaplot(table(Aids2$age)) areaplot(table(Aids2$age, Aids2$sex)) # ts/mts areaplot(austres) areaplot(Seatbelts[,c("drivers","front","rear")], ylab="Killed or seriously injured") abline(v=1983+1/12, lty=3) }