areaplot {areaplot} | R Documentation |
Area Plot
Description
Produce a stacked area plot, or add polygons to an existing plot.
Usage
areaplot(x, ...)
## Default S3 method:
areaplot(x, y = NULL, prop = FALSE, rev = FALSE,
add = FALSE, xlab = NULL, ylab = NULL, col = NULL, legend = FALSE,
args.legend = NULL, ...)
## S3 method for class 'formula'
areaplot(formula, data, subset, na.action, xlab = NULL,
ylab = NULL, ...)
Arguments
x |
a numeric vector of x values, or if |
... |
further arguments passed to |
y |
a numeric vector of y values, or a matrix containing y values in columns. |
prop |
whether data should be plotted as proportions, so stacked areas equal 1. |
rev |
whether to plot the stacked areas from bottom to top, instead of top to bottom. |
add |
whether polygons should be added to an existing plot. |
xlab |
a label for x axis. |
ylab |
a label for y axis. |
col |
fill color of polygon(s). The default is a vector of gray colors. |
legend |
a logical indicating whether a legend should be added, or a vector of strings for the legend. This only applies when more than one series is plotted. |
args.legend |
a list of additional arguments to pass to the
|
formula |
a |
data |
a data frame (or list) from which the variables in formula should be taken. |
subset |
an optional vector specifying a subset of observations to be used. |
na.action |
a function which indicates what should happen when the data
contain |
Value
Matrix of cumulative sums that was used for plotting.
See Also
polygon
is the underlying function used to draw polygons.
confplot
plots confidence bands as a filled area.
areaplot-package
gives an overview of the package.
Examples
areaplot(rpois(10,40))
areaplot(rnorm(10))
# formula
areaplot(Armed.Forces~Year, data=longley)
areaplot(cbind(Armed.Forces,Unemployed)~Year, data=longley)
areaplot(.~Year, data=longley)
areaplot(circumference~age+Tree, Orange)
# add=TRUE
plot(1940:1970, 500*runif(31), ylim=c(0,500))
areaplot(Armed.Forces~Year, data=longley, add=TRUE)
# data frame
mydata <- longley[c("Year","GNP")]
areaplot(mydata)
# 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)
# legend
require(MASS)
areaplot(table(Aids2$age, Aids2$sex), legend=TRUE, col=c(2,4))
areaplot(table(Aids2$age, Aids2$sex), legend=TRUE, col=c(2,4), rev=TRUE)
wp <- WorldPhones[,order(colnames(WorldPhones))]
areaplot(wp, col=2:8, legend=TRUE, args.legend=list(x="topleft"))
areaplot(wp, col=2:8, legend=TRUE, args.legend=list(x="topleft"), rev=TRUE)