| 42333 |
ripley |
1 |
% File src/library/graphics/man/plot.Rd
|
|
|
2 |
% Part of the R package, http://www.R-project.org
|
| 59039 |
ripley |
3 |
% Copyright 1995-2011 R Core Team
|
| 42333 |
ripley |
4 |
% Distributed under GPL 2 or later
|
|
|
5 |
|
| 27442 |
ripley |
6 |
\name{plot}
|
|
|
7 |
\title{Generic X-Y Plotting}
|
| 56186 |
murdoch |
8 |
\alias{plot}
|
| 56562 |
maechler |
9 |
\description{
|
|
|
10 |
Generic function for plotting of \R objects. For more details about
|
|
|
11 |
the graphical parameter arguments, see \code{\link{par}}.
|
|
|
12 |
|
|
|
13 |
For simple scatter plots, \code{\link{plot.default}} will be used.
|
|
|
14 |
However, there are \code{plot} methods for many \R objects,
|
|
|
15 |
including \code{\link{function}}s, \code{\link{data.frame}}s,
|
|
|
16 |
\code{\link{density}} objects, etc. Use \code{methods(plot)} and
|
|
|
17 |
the documentation for these.
|
|
|
18 |
}
|
| 27442 |
ripley |
19 |
\usage{
|
|
|
20 |
plot(x, y, \dots)
|
|
|
21 |
}
|
|
|
22 |
\arguments{
|
|
|
23 |
\item{x}{the coordinates of points in the plot. Alternatively, a
|
|
|
24 |
single plotting structure, function or \emph{any \R object with a
|
| 38888 |
ripley |
25 |
\code{plot} method} can be provided.}
|
| 27442 |
ripley |
26 |
\item{y}{the y coordinates of points in the plot, \emph{optional}
|
| 38888 |
ripley |
27 |
if \code{x} is an appropriate structure.}
|
| 56113 |
ripley |
28 |
\item{\dots}{Arguments to be passed to methods, such as
|
|
|
29 |
\link{graphical parameters} (see \code{\link{par}}).
|
| 38888 |
ripley |
30 |
Many methods will accept the following arguments:
|
| 46908 |
murdoch |
31 |
\describe{
|
| 36139 |
ripley |
32 |
\item{\code{type}}{what type of plot should be drawn. Possible types are
|
| 27442 |
ripley |
33 |
\itemize{
|
| 47621 |
ripley |
34 |
\item \code{"p"} for \bold{p}oints,
|
|
|
35 |
\item \code{"l"} for \bold{l}ines,
|
|
|
36 |
\item \code{"b"} for \bold{b}oth,
|
|
|
37 |
\item \code{"c"} for the lines part alone of \code{"b"},
|
|
|
38 |
\item \code{"o"} for both \sQuote{\bold{o}verplotted},
|
|
|
39 |
\item \code{"h"} for \sQuote{\bold{h}istogram} like (or
|
|
|
40 |
\sQuote{high-density}) vertical lines,
|
|
|
41 |
\item \code{"s"} for stair \bold{s}teps,
|
|
|
42 |
\item \code{"S"} for other \bold{s}teps, see \sQuote{Details} below,
|
|
|
43 |
\item \code{"n"} for no plotting.
|
| 27442 |
ripley |
44 |
}
|
|
|
45 |
All other \code{type}s give a warning or an error; using, e.g.,
|
|
|
46 |
\code{type = "punkte"} being equivalent to \code{type = "p"} for S
|
| 48610 |
ripley |
47 |
compatibility. Note that some methods,
|
|
|
48 |
e.g. \code{\link{plot.factor}}, do not accept this.
|
| 27442 |
ripley |
49 |
}
|
| 36139 |
ripley |
50 |
\item{\code{main}}{an overall title for the plot: see \code{\link{title}}.}
|
|
|
51 |
\item{\code{sub}}{a sub title for the plot: see \code{\link{title}}.}
|
|
|
52 |
\item{\code{xlab}}{a title for the x axis: see \code{\link{title}}.}
|
|
|
53 |
\item{\code{ylab}}{a title for the y axis: see \code{\link{title}}.}
|
| 38888 |
ripley |
54 |
\item{\code{asp}}{the \eqn{y/x} aspect ratio,
|
|
|
55 |
see \code{\link{plot.window}}.}
|
| 46908 |
murdoch |
56 |
}
|
| 27442 |
ripley |
57 |
}
|
|
|
58 |
}
|
|
|
59 |
\details{
|
|
|
60 |
The two step types differ in their x-y preference: Going from
|
|
|
61 |
\eqn{(x1,y1)} to \eqn{(x2,y2)} with \eqn{x1 < x2}, \code{type = "s"}
|
|
|
62 |
moves first horizontal, then vertical, whereas \code{type = "S"} moves
|
|
|
63 |
the other way around.
|
|
|
64 |
}
|
|
|
65 |
\seealso{
|
|
|
66 |
\code{\link{plot.default}}, \code{\link{plot.formula}} and other
|
|
|
67 |
methods; \code{\link{points}}, \code{\link{lines}}, \code{\link{par}}.
|
| 56562 |
maechler |
68 |
|
| 51681 |
ripley |
69 |
For X-Y-Z plotting see \code{\link{contour}}, \code{\link{persp}} and
|
|
|
70 |
\code{\link{image}}.
|
| 27442 |
ripley |
71 |
}
|
|
|
72 |
\examples{
|
| 41502 |
ripley |
73 |
require(stats)
|
| 27442 |
ripley |
74 |
plot(cars)
|
|
|
75 |
lines(lowess(cars))
|
|
|
76 |
|
| 56562 |
maechler |
77 |
plot(sin, -pi, 2*pi) # see ?plot.function
|
| 27442 |
ripley |
78 |
|
|
|
79 |
## Discrete Distribution Plot:
|
| 61168 |
ripley |
80 |
plot(table(rpois(100, 5)), type = "h", col = "red", lwd = 10,
|
|
|
81 |
main = "rpois(100, lambda = 5)")
|
| 27442 |
ripley |
82 |
|
| 27653 |
maechler |
83 |
## Simple quantiles/ECDF, see ecdf() {library(stats)} for a better one:
|
| 27442 |
ripley |
84 |
plot(x <- sort(rnorm(47)), type = "s", main = "plot(x, type = \"s\")")
|
|
|
85 |
points(x, cex = .5, col = "dark red")
|
|
|
86 |
}
|
|
|
87 |
\keyword{hplot}
|