Trellis Plot of a Time Series

DESCRIPTION:

Create a Trellis plot of a timeSeries object on the current plotting device. This function is the method for trellisPlot for objects of class timeSeries, but it can also be called directly.

USAGE:

trellisPlot.timeSeries(x, ..., subset=T, xlab="", ylab=<<see below>>,
                       plot.type=NULL, xlim=NULL, ylim=NULL,
                       scales=NULL, x.axis.args=NULL, y.axis.args=NULL,
                       log.axes="c", complex.convert=Mod,
                       layout=NULL, trellis.args=NULL,
                       frame.call=sys.nframe(),
                       frame.function=frame.call)

REQUIRED ARGUMENTS:

x
first time series to plot, or a list of time series. If it is a named list, those names will be used as the panel labels.

OPTIONAL ARGUMENTS:

...
additional time series or graphical arguments.
subset
a subscript vector appropriate for subscripting the data's x and y values. This can be a numeric vector with positive integers, one with negative integers indicating which observations should be omitted, or a logical vector.
xlab
title for the x-axis.
ylab
title for the y-axis; defaults to x@units or an empty string if this is NULL.
plot.type
a character string indicating the type of plot. Possible values are "line", "hloc", and "stackbar" for plotting lines/points, high-low-open-close bars, and stacked bars respectively. For stacked bar plots, the y-values given in the data represent the cumulative heights of bars; e.g. if you want three stacked bars of height 2, the y values should be 2, 4, and 6. plot.type may be a single character value, to use the same plot type for everything; a vector as long as the number of series arguments, to specify different plot types for each series; a list of length one to use the same plot types for each series, but specify different plotting types for the columns within the series; or a list as long as the number of series, where each list is a vector specifying plot types for each column in that series.
xlim
the range of x values to use for plotting.
ylim
the range of y values to use for plotting.
scales
a list with optional x and y components for passing into the scales argument of xyplot. Typically, this is used to make the x or y axes for each panel have separate scales, by setting the x or y component of scales to list(relation="free").
x.axis.args
a list of parameters to pass to the axis.time function for customizing the x-axis.
y.axis.args
a list of parameters to pass to the axis.numeric function for customizing the y-axis.
log.axes
set to "y" to make the y-axis logarithmic. Any other value makes it linear.
complex.convert
function used to convert complex numbers to real for plotting.
layout
the layout of the Trellis panels for the plot, e.g. c(2,3) for a two-row, three-column layout. If NULL, a layout that is as nearly square as possible will be calculated using the good.layout function.
trellis.args
a list of additional arguments to pass to the xyplot trellis plotting function; these can also be passed directly as part of ....
frame.call
frame to evaluate sys.call and deparse(substitute()) in to figure out data set names (passed to parse.time.series.dotargs) in parsing the ... arguments.
frame.function
frame to evaluate sys.function in to figure out the plot function arguments (passed to parse.time.series.dotargs) in parsing the ... arguments.

VALUE:

an object of class trellis, which is automatically plotted by print.trellis, using the panel.timeSeries panel function, which calls panel.stackbar once per time series to render stacked bar columns, panel.hloc once to render hloc columns, and panel.superpose once to render line plot columns.

DETAILS:

This function creates a Trellis plot of one or more time series objects. For each time series argument passed in the x or ... arguments, a single panel is created. If a time series is multivariate, all of the columns are plotted in the panel for that time series, typically with different line types or colors. Graphical arguments governing line type, color, and other parameters for Trellis plots of time series should be set using trellis.par.set. They are stored in the various Trellis data sets for the plotting devices, and designed to give good-looking plots with distinct styles for each column of each data set.

EXAMPLES:

# Plot high-low-close and volume for the djia time series in 1987
# Logical vector to select 1987 value:
t1987.p <- positions(djia) > timeDate("1/1/1987") & positions(djia) < timeDate("1/1/1988")
# The high-low-open-close values for 1987:
Hi.Low.Open.Close <- djia[t1987.p, 1:4]
# The volume for 1987:
Daily.Volume <- djia[t1987.p, "volume"]
# The plot:
trellisPlot(Hi.Low.Open.Close, Daily.Volume, 
        scales=list(y=list(relation="free")),
        plot.type=c("hloc", "stackbar"))

SEE ALSO:

, , , .