The R Project SVN R

Rev

Rev 27447 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 27447 Rev 27653
1
\name{plot}
1
\name{plot}
2
\title{Generic X-Y Plotting}
2
\title{Generic X-Y Plotting}
3
\alias{plot}
3
\alias{plot}
4
\usage{
4
\usage{
5
plot(x, y, \dots)
5
plot(x, y, \dots)
6
}
6
}
7
\arguments{
7
\arguments{
8
  \item{x}{the coordinates of points in the plot. Alternatively, a
8
  \item{x}{the coordinates of points in the plot. Alternatively, a
9
      single plotting structure, function or \emph{any \R object with a
9
      single plotting structure, function or \emph{any \R object with a
10
          \code{plot} method} can be provided.}
10
          \code{plot} method} can be provided.}
11
  \item{y}{the y coordinates of points in the plot, \emph{optional}
11
  \item{y}{the y coordinates of points in the plot, \emph{optional}
12
      if \code{x} is an appropriate structure.}
12
      if \code{x} is an appropriate structure.}
13
  \item{\dots}{graphical parameters can be given as arguments to
13
  \item{\dots}{graphical parameters can be given as arguments to
14
    \code{plot}.  Many methods will also accept the following arguments:
14
    \code{plot}.  Many methods will also accept the following arguments:
15
    
15
 
16
    \item{type}{what type of plot should be drawn.  Possible types are
16
    \item{type}{what type of plot should be drawn.  Possible types are
17
      \itemize{
17
      \itemize{
18
	\item \code{"p"} for \bold{p}oints,
18
	\item \code{"p"} for \bold{p}oints,
19
	\item \code{"l"} for \bold{l}ines,
19
	\item \code{"l"} for \bold{l}ines,
20
	\item \code{"b"} for \bold{b}oth,
20
	\item \code{"b"} for \bold{b}oth,
21
	\item \code{"c"} for the lines part alone of \code{"b"},
21
	\item \code{"c"} for the lines part alone of \code{"b"},
22
	\item \code{"o"} for both \dQuote{\bold{o}verplotted},
22
	\item \code{"o"} for both \dQuote{\bold{o}verplotted},
23
	\item \code{"h"} for \dQuote{\bold{h}istogram} like (or
23
	\item \code{"h"} for \dQuote{\bold{h}istogram} like (or
24
	\dQuote{high-density}) vertical lines,
24
	\dQuote{high-density}) vertical lines,
25
	\item \code{"s"} for stair \bold{s}teps,
25
	\item \code{"s"} for stair \bold{s}teps,
26
	\item \code{"S"} for other \bold{s}teps, see \emph{Details} below,
26
	\item \code{"S"} for other \bold{s}teps, see \emph{Details} below,
27
	\item \code{"n"} for no plotting.
27
	\item \code{"n"} for no plotting.
28
      }
28
      }
29
      All other \code{type}s give a warning or an error; using, e.g.,
29
      All other \code{type}s give a warning or an error; using, e.g.,
30
      \code{type = "punkte"} being equivalent to \code{type = "p"} for S
30
      \code{type = "punkte"} being equivalent to \code{type = "p"} for S
31
      compatibility.
31
      compatibility.
32
    }
32
    }
33
    \item{main}{an overall title for the plot: see \code{\link{title}}.}
33
    \item{main}{an overall title for the plot: see \code{\link{title}}.}
34
    \item{sub}{a sub title for the plot: see \code{\link{title}}.}
34
    \item{sub}{a sub title for the plot: see \code{\link{title}}.}
35
    \item{xlab}{a title for the x axis: see \code{\link{title}}.}
35
    \item{xlab}{a title for the x axis: see \code{\link{title}}.}
36
    \item{ylab}{a title for the y axis: see \code{\link{title}}.}
36
    \item{ylab}{a title for the y axis: see \code{\link{title}}.}
37
  }
37
  }
38
}
38
}
39
\description{
39
\description{
40
  Generic function for plotting of \R objects.  For more details about
40
  Generic function for plotting of \R objects.  For more details about
41
  the graphical parameter arguments, see \code{\link{par}}.
41
  the graphical parameter arguments, see \code{\link{par}}.
42
}
42
}
43
\details{
43
\details{
44
  For simple scatter plots, \code{\link{plot.default}} will be used.
44
  For simple scatter plots, \code{\link{plot.default}} will be used.
45
  However, there are \code{plot} methods for many \R objects,
45
  However, there are \code{plot} methods for many \R objects,
46
  including \code{\link{function}}s, \code{\link{data.frame}}s,
46
  including \code{\link{function}}s, \code{\link{data.frame}}s,
47
  \code{\link[stats]{density}} objects, etc.  Use \code{methods(plot)} and
47
  \code{\link[stats]{density}} objects, etc.  Use \code{methods(plot)} and
48
  the documentation for these.
48
  the documentation for these.
49
 
49
 
50
  The two step types differ in their x-y preference: Going from
50
  The two step types differ in their x-y preference: Going from
51
  \eqn{(x1,y1)} to \eqn{(x2,y2)} with \eqn{x1 < x2}, \code{type = "s"}
51
  \eqn{(x1,y1)} to \eqn{(x2,y2)} with \eqn{x1 < x2}, \code{type = "s"}
52
  moves first horizontal, then vertical, whereas \code{type = "S"} moves
52
  moves first horizontal, then vertical, whereas \code{type = "S"} moves
53
  the other way around.
53
  the other way around.
54
}
54
}
55
\seealso{
55
\seealso{
56
  \code{\link{plot.default}}, \code{\link{plot.formula}} and other
56
  \code{\link{plot.default}}, \code{\link{plot.formula}} and other
57
  methods; \code{\link{points}}, \code{\link{lines}}, \code{\link{par}}.
57
  methods; \code{\link{points}}, \code{\link{lines}}, \code{\link{par}}.
58
}
58
}
59
\examples{
59
\examples{
60
data(cars)
60
data(cars)
61
plot(cars)
61
plot(cars)
62
lines(lowess(cars))
62
lines(lowess(cars))
63
 
63
 
64
plot(sin, -pi, 2*pi)
64
plot(sin, -pi, 2*pi)
65
 
65
 
66
## Discrete Distribution Plot:
66
## Discrete Distribution Plot:
67
plot(table(rpois(100,5)), type = "h", col = "red", lwd=10,
67
plot(table(rpois(100,5)), type = "h", col = "red", lwd=10,
68
     main="rpois(100,lambda=5)")
68
     main="rpois(100,lambda=5)")
69
 
69
 
70
## Simple quantiles/ECDF, see ecdf() {library(stepfun)} for a better one:
70
## Simple quantiles/ECDF, see ecdf() {library(stats)} for a better one:
71
plot(x <- sort(rnorm(47)), type = "s", main = "plot(x, type = \"s\")")
71
plot(x <- sort(rnorm(47)), type = "s", main = "plot(x, type = \"s\")")
72
points(x, cex = .5, col = "dark red")
72
points(x, cex = .5, col = "dark red")
73
}
73
}
74
\keyword{hplot}
74
\keyword{hplot}