Plots input data as a stack of plots.
stackPlot(x, y = NULL, xlty = NULL, bty = "n", lty = 1, col = 1:8,
lwd = 1, rescale = TRUE, add = FALSE, cex = 1, xaxs = "r", xpd = TRUE,
yaxis = list(add = TRUE, ndigit = 3,
col = 1:8, lty = 1, lwd = 3, side = "left", cex = 1),
xlab = list(text = "", cex = 1, srt = 0, col = 1), ylab = list(text = NULL,
cex = 1, srt = 0, col = 1:8, side = "right"), main = list(text = "",
cex = 1, srt = 0, col = 1, adj = 0.5), ylim = NULL)
no output.
a vector of numeric values corresponding to a common abscissa (x-axis) for all ordinate (y-axis) values.
a numeric vector, matrix, data.frame, or rectangular list containing the ordinate (y-axis) values.
a logical value. If TRUE
, the plot is added using the current
par
layout. Otherwise a new plot is produced. Default: FALSE
.
a character string defining the box type (ala par
's bty
parameter)
for each plot. Default: "n"
(no boxes).
a numeric value defining the character expansion for the plot labels (ala par
's cex
parameter).
Default: 1.
an integer or vector of integers denoting the color of each
plotted series (ala par
's col
parameter). This
input can be a vector, one color for each series plotted. If the length
of this vector is less than the number of series, then col
is repeated as many
times as necessary. Default: 1:8
.
the line type for each plot (ala par
's lty
parameter). This
input can be a vector, one line type for each series plotted. If the length
of this vector is less than the number of series, then lty=1
is used for those
plots where lty is not directly specified. Default: 1.
an integer or vector of integers denoting the line width of each
plotted series (ala par
's lwd
parameter). This
input can be a vector, one line width for each series plotted. If the length
of this vector is less than the number of series, then lwd
is repeated as many
times as necessary. Default: 1.
the main label as defined by a list of the following named objects:
A character string defining the label. Default: ""
(no label).
A character expansion value used to scale the label. Default: 1.
A numerical value specifying the rotation of the label in degrees. Default: 0.
An integer defining the color of the label. Default: 1.
A numeric value on [0,1] defining the justification of the label relative to the entire width of the plot window. The value 0, 0.5, and 1 represent left, center, and right text alignment, respectively. Default: 0.5.
If a partial list of the above named objects is supplied, those objects are merged with the default list defined above.
a logical value. If TRUE
, the data in each plot is scaled so that
visually the height of each subplot is approximately the same (the y-axis labels denote
the unscaled/original values. Default: TRUE
.
a character string defining the style of the x-axis
interval calculation (ala par
's xaxs
parameter). Default: "e"
(extended axes).
the x-axis label as defined by a list of the following named objects:
A character string defining the label. Default: ""
(no label).
A character expansion value used to scale the label. Default: 1.
A numerical value specifying the rotation of the label in degrees. Default: 0.
An integer defining the color of the label. Default: 1.
If a partial list of the above named objects is supplied, those objects are merged with the default list defined above.
the line type (ala par
's lty
parameter) of
horizontal lines used to separate stacked plots. Default: NULL
(no separator lines).
a character string defining the style of the plot clipping
(ala par
's xpd
parameter). Default: TRUE
.
the y-axis style as defined by a list of the following named objects:
A logical value. If TRUE
, a y-axis is drawn for each plot. Default: TRUE
.
An integer defining the number of digits to use in labeling y-axis data ranges. Default: 3.
An integer defining the line width of the y-axis. Default: 3.
A character string (either "left"
or "right"
denoting
the side to place the y-axis. Default: "left"
.
A character expansion value used to scale the labels on the y-axis. Default: 1.
If a partial list of the above named objects is supplied, those objects are merged with the default list defined above.
the y-axis label(s) as defined by a list of the following named objects:
A (vector of) character string(s) defining the label(s).
Default: the names of the y-axis labels as labeled in the primary y
input.
A character expansion value used to scale the label(s). Default: 1.
A numerical value specifying the rotation of the label(s) in degrees. Default: 0.
A (vector of) integer(s) defining the color of the label(s). Default: 1:8
.
A character string (either "left"
or "right"
denoting
the side to place the y-axis label(s). Default: "right"
.
If a partial list of the above named objects is supplied, those objects are merged with the default list defined above.
a two-element numeric vector containing the y-axis range of each series
to plot. The range of the specified ylim
values must span that of all the series,
otherwise an error is returned. Default: NULL
(y-axis limits are calculated automatically).
splitplot
.
## stack-plot the sunspots series and a random
## walk series
set.seed(100)
ix <- seq(2048)
stackPlot(x=ix,
y=data.frame(sunspots[ix], cumsum(rnorm(length(ix)))),
xlty=2, ylab=list(text=c("sunspots","walk")))
Run the code above in your browser using DataLab