| 42333 |
ripley |
1 |
% File src/library/stats/man/plot.ts.Rd
|
| 68948 |
ripley |
2 |
% Part of the R package, https://www.R-project.org
|
| 59039 |
ripley |
3 |
% Copyright 1995-2007 R Core Team
|
| 42333 |
ripley |
4 |
% Distributed under GPL 2 or later
|
|
|
5 |
|
| 27442 |
ripley |
6 |
\name{plot.ts}
|
| 56186 |
murdoch |
7 |
\alias{plot.ts}
|
| 27442 |
ripley |
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"),
|
| 29402 |
maechler |
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)
|
| 27442 |
ripley |
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
|
| 68055 |
ripley |
25 |
plotted separately (with a common time axis) or on a single plot?
|
|
|
26 |
Can be abbreviated.}
|
| 27442 |
ripley |
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
|
| 61160 |
ripley |
39 |
\code{plot.type = "multiple"}. The default is \code{lines}.}
|
| 27442 |
ripley |
40 |
|
| 61160 |
ripley |
41 |
\item{nc}{the number of columns to use when \code{type = "multiple"}.
|
| 27442 |
ripley |
42 |
Defaults to 1 for up to 4 series, otherwise to 2.}
|
| 29402 |
maechler |
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
|
| 61160 |
ripley |
45 |
when \code{type = "multiple"}.}
|
| 29542 |
maechler |
46 |
\item{mar.multi, oma.multi}{the (default) \code{\link{par}} settings
|
| 61160 |
ripley |
47 |
for \code{plot.type = "multiple"}. Modify with care!}
|
| 29542 |
maechler |
48 |
\item{axes}{logical indicating if x- and y- axes should be drawn.}
|
| 27442 |
ripley |
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,
|
| 42961 |
ripley |
58 |
and a scatter plot \code{y ~ x} will be drawn, enhanced by
|
| 27442 |
ripley |
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{
|
| 41508 |
ripley |
68 |
require(graphics)
|
|
|
69 |
|
| 27442 |
ripley |
70 |
## Multivariate
|
| 44243 |
ripley |
71 |
z <- ts(matrix(rt(200 * 8, df = 3), 200, 8),
|
|
|
72 |
start = c(1961, 1), frequency = 12)
|
| 29402 |
maechler |
73 |
plot(z, yax.flip = TRUE)
|
| 41621 |
ripley |
74 |
plot(z, axes = FALSE, ann = FALSE, frame.plot = TRUE,
|
|
|
75 |
mar.multi = c(0,0,0,0), oma.multi = c(1,1,5,1))
|
| 29402 |
maechler |
76 |
title("plot(ts(..), axes=FALSE, ann=FALSE, frame.plot=TRUE, mar..., oma...)")
|
|
|
77 |
|
|
|
78 |
z <- window(z[,1:3], end = c(1969,12))
|
| 27442 |
ripley |
79 |
plot(z, type = "b") # multiple
|
| 61160 |
ripley |
80 |
plot(z, plot.type = "single", lty = 1:3, col = 4:2)
|
| 27442 |
ripley |
81 |
|
|
|
82 |
## A phase plot:
|
| 61160 |
ripley |
83 |
plot(nhtemp, lag(nhtemp, 1), cex = .8, col = "blue",
|
| 27442 |
ripley |
84 |
main = "Lag plot of New Haven temperatures")
|
|
|
85 |
|
|
|
86 |
## xy.lines and xy.labels are FALSE for large series:
|
|
|
87 |
plot(lag(sunspots, 1), sunspots, pch = ".")
|
|
|
88 |
|
|
|
89 |
SMI <- EuStockMarkets[, "SMI"]
|
|
|
90 |
plot(lag(SMI, 1), SMI, pch = ".")
|
|
|
91 |
plot(lag(SMI, 20), SMI, pch = ".", log = "xy",
|
| 61160 |
ripley |
92 |
main = "4 weeks lagged SMI stocks -- log scale", xy.lines = TRUE)
|
| 27442 |
ripley |
93 |
}
|
|
|
94 |
\keyword{hplot}
|
|
|
95 |
\keyword{ts}
|