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