Learn R Programming

wavelets (version 0.2-5)

stackplot: Stacked Plotting

Description

Plot an object as a stacked set of plots, plotting each column using the same x-axis and plotting the y-values at the same scale with an offset equal to the magnitude of each column vector.

Usage

stackplot(x, y = NULL, type = "h", axes.labels = FALSE,
xlab = "", ylab = "", y.llabs = NULL, y.rlabs = NULL, draw.divides =
TRUE, xtick.at = NULL, ytick.at = NULL, col = "black", main = "")

Arguments

Details

Each object specified by x or y will be coerced into a list, and each object of the list will be coerced into a matrix using the function as.matrix. Each column of a matrix will represent the vertical y-values for each individual plot in the stacked plot. Horizontal x-values are discussed below. stackplot will plot a matrix of values as a series of stacked plots, where the individual columns are plotted using the same x and y scales, but offset by the magnitude (= abs(max-min)) of the column. If the object to be plotted is a Time Series object, the start and end values of the object will represent the first and last horizontal x-values of the points to be plotted. The Time Series will be coerced into matrix. The limits of the horizontal x-axis and vertical y-axis will be dictated by the data in the first object of the list. If the object to be plotted is a list of matrices, and x is not specified, the horizontal x-values of the points to be plotted for a given matrix will default to the rownames of that matrix. The rownames can be either numeric or character. If the first matrix of the list does not have rownames, then the horizontal x-values for each matrix (and its corresponding plot) will default to range from 1 to the length of the columns of the respective matrix. If the first matrix of the list does have specified rownames, then the horizontal x-values assume the values of the rownames of the respective matrix. However, if another matrix of the list does not have specified rownames, then its horizontal x-values will default to range from 1 to the length of the columns of that respective matrix. The user can specify the type of plot (currently only "h" and "l") to be drawn for every element of the list in x or y using the vector type. If the Nth element (N>1) in type is NA and the Nth element of the list in x or y exists, then the type of plot for the Nth element of the list will be equal to the type of plot for the N-1th element of the list. Similarly for col, which specifies the colors for each element of the list in x or y. The labels y.llabs and y.rlabs will be placed at the "zero" lines of each individual plot starting from the bottom working up to the top.

See Also

plot.dwt and plot.modwt

Examples

Run this code
A <- array(c(1,2,3,4), c(3,4))

# Plotting the vectors c(1,2,3), c(4,1,2), c(3,4,1), and c(2,3,4) in a
# stacked plot with 4 separate plots).  The x-values will be 1:3.
stackplot(A)

#Plotting A with numeric labels on the axis and making the plot "red".
#Also labeling the x-axis with "X-Label", and the y-axis with "Y-Label".
stackplot(A, axes.labels = TRUE, xlab = "X-Label", ylab = "Y-Label")

timeSeries <- ts(A)
# Plotting the Time Series created by coercing the array A into a Time
# Series.  Observe that this plot similar to the plot in the first example.
stackplot(timeSeries)

lfig <- 2:11
hfig <- 1:10
# Plotting a stacked plot of two types: histogram and lines.  Where the
# line joins the points (1,2) and (10,11), and the histogram is similar to
# the histogram formed by entering plot(1:10, type = "h").  The line will
# be red and the histogram will be yellow.
stackplot(list(lfig, hfig), type = c("l", "h"), col = c("red", "yellow"))

Run the code above in your browser using DataLab