1% File src/library/stats/man/plot.ts.Rd 2% Part of the R package, https://www.R-project.org 3% Copyright 1995-2007 R Core Team 4% Distributed under GPL 2 or later 5 6\name{plot.ts} 7\alias{plot.ts} 8\alias{lines.ts} 9\title{Plotting Time-Series Objects} 10\description{ 11 Plotting method for objects inheriting from class \code{"ts"}. 12} 13\usage{ 14\method{plot}{ts}(x, y = NULL, plot.type = c("multiple", "single"), 15 xy.labels, xy.lines, panel = lines, nc, yax.flip = FALSE, 16 mar.multi = c(0, 5.1, 0, if(yax.flip) 5.1 else 2.1), 17 oma.multi = c(6, 0, 5, 0), axes = TRUE, \dots) 18 19\method{lines}{ts}(x, \dots) 20} 21\arguments{ 22 \item{x, y}{time series objects, usually inheriting from class \code{"ts"}.} 23 24 \item{plot.type}{for multivariate time series, should the series by 25 plotted separately (with a common time axis) or on a single plot? 26 Can be abbreviated.} 27 28 \item{xy.labels}{logical, indicating if \code{\link{text}()} labels 29 should be used for an x-y plot, \emph{or} character, supplying a 30 vector of labels to be used. The default is to label for up to 150 31 points, and not for more.} 32 33 \item{xy.lines}{logical, indicating if \code{\link{lines}} 34 should be drawn for an x-y plot. Defaults to the value of 35 \code{xy.labels} if that is logical, otherwise to \code{TRUE}.} 36 37 \item{panel}{a \code{function(x, col, bg, pch, type, ...)} which gives the 38 action to be carried out in each panel of the display for 39 \code{plot.type = "multiple"}. The default is \code{lines}.} 40 41 \item{nc}{the number of columns to use when \code{type = "multiple"}. 42 Defaults to 1 for up to 4 series, otherwise to 2.} 43 \item{yax.flip}{logical indicating if the y-axis (ticks and numbering) 44 should flip from side 2 (left) to 4 (right) from series to series 45 when \code{type = "multiple"}.} 46 \item{mar.multi, oma.multi}{the (default) \code{\link{par}} settings 47 for \code{plot.type = "multiple"}. Modify with care!} 48 \item{axes}{logical indicating if x- and y- axes should be drawn.} 49 \item{\dots}{additional graphical arguments, see \code{\link{plot}}, 50 \code{\link{plot.default}} and \code{\link{par}}.} 51} 52\details{ 53 If \code{y} is missing, this function creates a time series 54 plot, for multivariate series of one of two kinds depending on 55 \code{plot.type}. 56 57 If \code{y} is present, both \code{x} and \code{y} must be univariate, 58 and a scatter plot \code{y ~ x} will be drawn, enhanced by 59 using \code{\link{text}} if \code{xy.labels} is 60 \code{\link{TRUE}} or \code{character}, and \code{\link{lines}} if 61 \code{xy.lines} is \code{TRUE}. 62} 63\seealso{ 64 \code{\link{ts}} for basic time series construction and access 65 functionality. 66} 67\examples{ 68require(graphics) 69 70## Multivariate 71z <- ts(matrix(rt(200 * 8, df = 3), 200, 8), 72 start = c(1961, 1), frequency = 12) 73plot(z, yax.flip = TRUE) 74plot(z, axes = FALSE, ann = FALSE, frame.plot = TRUE, 75 mar.multi = c(0,0,0,0), oma.multi = c(1,1,5,1)) 76title("plot(ts(..), axes=FALSE, ann=FALSE, frame.plot=TRUE, mar..., oma...)") 77 78z <- window(z[,1:3], end = c(1969,12)) 79plot(z, type = "b") # multiple 80plot(z, plot.type = "single", lty = 1:3, col = 4:2) 81 82## A phase plot: 83plot(nhtemp, lag(nhtemp, 1), cex = .8, col = "blue", 84 main = "Lag plot of New Haven temperatures") 85 86## xy.lines and xy.labels are FALSE for large series: 87plot(lag(sunspots, 1), sunspots, pch = ".") 88 89SMI <- EuStockMarkets[, "SMI"] 90plot(lag(SMI, 1), SMI, pch = ".") 91plot(lag(SMI, 20), SMI, pch = ".", log = "xy", 92 main = "4 weeks lagged SMI stocks -- log scale", xy.lines = TRUE) 93} 94\keyword{hplot} 95\keyword{ts} 96