The R Project SVN R

Rev

Rev 59039 | Rev 68055 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
42333 ripley 1
% File src/library/stats/man/plot.ts.Rd
2
% Part of the R package, http://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
25
    plotted separately (with a common time axis) or on a single plot?}
26
 
27
  \item{xy.labels}{logical, indicating if \code{\link{text}()} labels
28
    should be used for an x-y plot, \emph{or} character, supplying a
29
    vector of labels to be used.  The default is to label for up to 150
30
    points, and not for more.}
31
 
32
  \item{xy.lines}{logical, indicating if \code{\link{lines}}
33
    should be drawn for an x-y plot.  Defaults to the value of
34
    \code{xy.labels} if that is logical, otherwise to \code{TRUE}.}
35
 
36
  \item{panel}{a \code{function(x, col, bg, pch, type, ...)} which gives the
37
    action to be carried out in each panel of the display for
61160 ripley 38
    \code{plot.type = "multiple"}.  The default is \code{lines}.}
27442 ripley 39
 
61160 ripley 40
  \item{nc}{the number of columns to use when \code{type = "multiple"}.
27442 ripley 41
    Defaults to 1 for up to 4 series, otherwise to 2.}
29402 maechler 42
  \item{yax.flip}{logical indicating if the y-axis (ticks and numbering)
43
    should flip from side 2 (left) to 4 (right) from series to series
61160 ripley 44
    when \code{type = "multiple"}.}
29542 maechler 45
  \item{mar.multi, oma.multi}{the (default) \code{\link{par}} settings
61160 ripley 46
    for \code{plot.type = "multiple"}.  Modify with care!}
29542 maechler 47
  \item{axes}{logical indicating if x- and y- axes should be drawn.}
27442 ripley 48
  \item{\dots}{additional graphical arguments, see \code{\link{plot}},
49
    \code{\link{plot.default}} and \code{\link{par}}.}
50
}
51
\details{
52
  If \code{y} is missing, this function creates a time series
53
  plot, for multivariate series of one of two kinds depending on
54
  \code{plot.type}.
55
 
56
  If \code{y} is present, both \code{x} and \code{y} must be univariate,
42961 ripley 57
  and a scatter plot \code{y ~ x} will be drawn, enhanced by
27442 ripley 58
  using \code{\link{text}} if \code{xy.labels} is
59
  \code{\link{TRUE}} or \code{character}, and \code{\link{lines}} if
60
  \code{xy.lines} is \code{TRUE}.
61
}
62
\seealso{
63
  \code{\link{ts}} for basic time series construction and access
64
  functionality.
65
}
66
\examples{
41508 ripley 67
require(graphics)
68
 
27442 ripley 69
## Multivariate
44243 ripley 70
z <- ts(matrix(rt(200 * 8, df = 3), 200, 8),
71
        start = c(1961, 1), frequency = 12)
29402 maechler 72
plot(z, yax.flip = TRUE)
41621 ripley 73
plot(z, axes = FALSE, ann = FALSE, frame.plot = TRUE,
74
     mar.multi = c(0,0,0,0), oma.multi = c(1,1,5,1))
29402 maechler 75
title("plot(ts(..), axes=FALSE, ann=FALSE, frame.plot=TRUE, mar..., oma...)")
76
 
77
z <- window(z[,1:3], end = c(1969,12))
27442 ripley 78
plot(z, type = "b")    # multiple
61160 ripley 79
plot(z, plot.type = "single", lty = 1:3, col = 4:2)
27442 ripley 80
 
81
## A phase plot:
61160 ripley 82
plot(nhtemp, c(nhtemp[-1], NA), cex = .8, col = "blue",
27442 ripley 83
     main = "Lag plot of New Haven temperatures")
84
## a clearer way to do this would be
28841 ripley 85
\dontrun{
61160 ripley 86
plot(nhtemp, lag(nhtemp, 1), cex = .8, col = "blue",
27442 ripley 87
     main = "Lag plot of New Haven temperatures")
88
}
89
 
90
## xy.lines and xy.labels are FALSE for large series:
91
plot(lag(sunspots, 1), sunspots, pch = ".")
92
 
93
SMI <- EuStockMarkets[, "SMI"]
94
plot(lag(SMI,  1), SMI, pch = ".")
95
plot(lag(SMI, 20), SMI, pch = ".", log = "xy",
61160 ripley 96
     main = "4 weeks lagged SMI stocks -- log scale", xy.lines =  TRUE)
27442 ripley 97
}
98
\keyword{hplot}
99
\keyword{ts}