zoo (version 1.0-1)

plot.zoo: Plotting zoo Objects

Description

Plotting method for objects of class "zoo".

Usage

## S3 method for class 'zoo':
plot(x, screens = 1, plot.type = c("multiple", "single"),
  panel = lines, xlab = "Index", ylab = NULL, main = NULL,
  ylim = NULL, oma = c(6, 0, 5, 0), mar = c(0, 5.1, 0, 2.1), 
  col = 1, lty = 1, pch = 1, type = "l", nc, widths = 1, heights = 1, ...)
## S3 method for class 'zoo':
lines(x, type = "l", \dots)

Arguments

x
an object of class "zoo".
screens
factor (or coerced to factor) whose levels specify which graph each series is to be plotted in. screens=c(1,2,1) would plot series 1, 2 and 3 in graphs 1, 2 and 1.
plot.type
for multivariate zoo objects, "multiple" plots the series on multiple plots and "single" superimposes them on a single plot
panel
a function(x, y, col, lty, ...) which gives the action to be carried out in each panel of the display for plot.type = "multiple".
ylim
if plot.type = "multiple" then it can be a list of y axis limits. If not a list each graph has the same limits. If any list element is not a pair then its range is used instead. If plot.type = "single" then it is
xlab, ylab, main, oma, mar
graphical arguments, see par.
col, lty, pch, type
graphical arguments that can be vectors or (named) lists. See the details for more information.
nc
the number of columns to use when plot.type = "multiple". Defaults to 1 for up to 4 series, otherwise to 2.
widths, heights
widths and heights for individual graphs, see layout.
...
additional graphical arguments.

Details

The methods for plot and lines are very similar to the corresponding ts methods. However, the handling of graphical parameters col, pch and lty is more flexible for multivariate series. These parameters can be vectors of the same length as the number of series plotted or are recycled if shorter. They can also be (partially) named list, e.g., list(A = c(1,2), c(3,4)) in which c(3, 4) is the default value and c(1, 2) the value only for series A. The screens argument can be specified in a similar way. If plot.type and screens conflict then multiple plots will be assumed. Also see the examples.

See Also

zoo, plot.ts

Examples

Run this code
x.Date <- as.Date(paste(2003, 02, c(1, 3, 7, 9, 14), sep = "-"))

## univariate plotting
x <- zoo(rnorm(5), x.Date)
x2 <- zoo(rnorm(5, sd = 0.2), x.Date)
plot(x)
lines(x2, col = 2)

## multivariate plotting
z <- cbind(x, x2, zoo(rnorm(5, sd = 0.5), x.Date))
colnames(z) <- LETTERS[1:3]
plot(z, plot.type = "single", col = list(B = 2))
plot(z, type = "b", pch = 1:3, col = 1:3)
plot(z, type = "b", pch = list(A = 1:5, B = 3), col = list(C = 4, 2))
plot(z, type = "b", screen = c(1,2,1), col = 1:3)

## plot one zoo series against the other.  This does NOT dispatch plot.zoo.
plot(coredata(merge(x, x2)))

Run the code above in your browser using DataCamp Workspace