The R Project SVN R

Rev

Rev 27442 | Rev 34546 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 27442 Rev 28166
Line 1... Line 1...
1
\name{axis.POSIXct}
1
\name{axis.POSIXct}
2
\alias{axis.POSIXct}
2
\alias{axis.POSIXct}
3
\alias{plot.POSIXct}
3
\alias{plot.POSIXct}
4
\alias{plot.POSIXlt}
4
\alias{plot.POSIXlt}
-
 
5
\alias{axis.Date}
-
 
6
\alias{plot.Date}
5
\title{Date-time Plotting Functions}
7
\title{Date and Date-time Plotting Functions}
6
\description{
8
\description{
7
  Functions to plot objects of classes \code{"POSIXlt"} and
9
  Functions to plot objects of classes \code{"POSIXlt"},
8
  \code{"POSIXct"} representing calendar dates and times. 
10
  \code{"POSIXct"} and \code{"Date"}  representing calendar dates and times. 
9
}
11
}
10
\usage{
12
\usage{
11
axis.POSIXct(side, x, at, format, \dots)
13
axis.POSIXct(side, x, at, format, \dots)
12
 
14
 
-
 
15
axis.Date(side, x, at, format, \dots)
-
 
16
 
13
\method{plot}{POSIXct}(x, y, xlab = "", \dots)
17
\method{plot}{POSIXct}(x, y, xlab = "", \dots)
14
 
18
 
15
\method{plot}{POSIXlt}(x, y, xlab = "", \dots)
19
\method{plot}{POSIXlt}(x, y, xlab = "", \dots)
-
 
20
 
-
 
21
\method{plot}{Date}(x, y, xlab = "", \dots)
16
}
22
}
17
\synopsis{
23
\synopsis{
18
plot.POSIXct(x, y, xlab = "", axes = TRUE, frame.plot = axes, xaxt = par("xaxt"), ...)
24
plot.POSIXct(x, y, xlab = "", axes = TRUE, frame.plot = axes, xaxt = par("xaxt"), ...)
19
plot.POSIXlt(x, y, xlab = "", axes = TRUE, frame.plot = axes, xaxt = par("xaxt"), ...)
25
plot.POSIXlt(x, y, xlab = "", axes = TRUE, frame.plot = axes, xaxt = par("xaxt"), ...)
-
 
26
plot.Date(x, y, xlab = "", axes = TRUE, frame.plot = axes, xaxt = par("xaxt"), ...)
20
axis.POSIXct(side, x, at, format, ...)
27
axis.POSIXct(side, x, at, format, ...)
-
 
28
axis.Date(side, x, at, format, ...)
21
}
29
}
22
\arguments{
30
\arguments{
23
  \item{x, at}{A date-time object.}
31
  \item{x, at}{A date-time object.}
24
  \item{y}{numeric values to be plotted against \code{x}.}
32
  \item{y}{numeric values to be plotted against \code{x}.}
25
  \item{xlab}{a character string giving the label for the x axis.}
33
  \item{xlab}{a character string giving the label for the x axis.}
Line 29... Line 37...
29
    typically graphical parameters or arguments of
37
    typically graphical parameters or arguments of
30
    \code{\link{plot.default}}.}
38
    \code{\link{plot.default}}.}
31
}
39
}
32
\details{
40
\details{
33
  The functions plot against an x-axis of date-times.
41
  The functions plot against an x-axis of date-times.
34
  \code{axis.POSIXct} works quite hard to choose suitable time units
42
  \code{axis.POSIXct} and \code{axis.Date} work quite hard to choose
35
  (years, months, days, hours, minutes or seconds) and a sensible
43
  suitable time units (years, months, days, hours, minutes or seconds)
36
  output format, but this can be overridden by supplying a \code{format}
44
  and a sensible output format, but this can be overridden by supplying
37
  specification.
45
  a \code{format} specification.
38
 
46
 
39
  If \code{at} is supplied for \code{axis.POSIXct} it specifies the
47
  If \code{at} is supplied it specifies the locations of the ticks
40
  locations of the ticks and labels: if \code{x} is specified a
48
  and labels whereas if \code{x} is specified a suitable grid of labels
41
  suitable grid of labels is chosen. 
49
  is chosen. 
42
}
50
}
43
\seealso{
51
\seealso{
44
  \link{DateTimeClasses} for details of the classes.
52
  \link{DateTimeClasses}, \link{Dates} for details of the classes.
45
}
53
}
46
\examples{
54
\examples{
47
res <- try(data(beav1, package = "MASS"))
55
res <- try(data(beav1, package = "MASS"))
48
if(!inherits(res, "try-error")) {
56
if(!inherits(res, "try-error")) {
49
attach(beav1)
57
attach(beav1)
Line 59... Line 67...
59
}
67
}
60
 
68
 
61
plot(.leap.seconds, 1:22, type="n", yaxt="n",
69
plot(.leap.seconds, 1:22, type="n", yaxt="n",
62
     xlab="leap seconds", ylab="", bty="n")
70
     xlab="leap seconds", ylab="", bty="n")
63
rug(.leap.seconds)
71
rug(.leap.seconds)
-
 
72
## or as dates
-
 
73
lps <- as.Date(.leap.seconds)
-
 
74
plot(lps, 1:22, type="n", yaxt="n", xlab="leap seconds", ylab="", bty="n")
-
 
75
rug(lps)
-
 
76
 
-
 
77
## 100 random dates in a 10-week period
-
 
78
random.dates <- as.Date("2001/1/1") + 70*sort(runif(100))
-
 
79
plot(random.dates, 1:100)
-
 
80
# or for a better axis labelling
-
 
81
plot(random.dates, 1:100, xaxt="n")
-
 
82
axis.Date(1, at=seq(as.Date("2001/1/1"), max(random.dates)+6, "weeks"))
64
}
83
}
65
\keyword{utilities}
84
\keyword{utilities}
66
\keyword{chron}
85
\keyword{chron}