| 27442 |
ripley |
1 |
\name{plot.default}
|
|
|
2 |
\alias{plot.default}
|
|
|
3 |
\title{The Default Scatterplot Function}
|
|
|
4 |
\description{
|
|
|
5 |
Draw a scatter plot with \dQuote{decorations} such as axes and titles
|
|
|
6 |
in the active graphics window.
|
|
|
7 |
}
|
|
|
8 |
\usage{
|
|
|
9 |
\method{plot}{default}(x, y = NULL, type = "p", xlim = NULL, ylim = NULL,
|
|
|
10 |
log = "", main = NULL, sub = NULL, xlab = NULL, ylab = NULL,
|
|
|
11 |
ann = par("ann"), axes = TRUE, frame.plot = axes,
|
|
|
12 |
panel.first = NULL, panel.last = NULL,
|
|
|
13 |
col = par("col"), bg = NA, pch = par("pch"),
|
|
|
14 |
cex = 1, lty = par("lty"), lab = par("lab"),
|
|
|
15 |
lwd = par("lwd"), asp = NA, \dots)
|
|
|
16 |
}
|
|
|
17 |
\arguments{
|
|
|
18 |
\item{x,y}{the \code{x} and \code{y} arguments provide the x and y
|
|
|
19 |
coordinates for the plot. Any reasonable way of defining the
|
|
|
20 |
coordinates is acceptable. See the function \code{\link{xy.coords}}
|
|
|
21 |
for details.}
|
|
|
22 |
\item{type}{1-character string giving the type of plot desired. The
|
|
|
23 |
following values are possible, for details, see \code{\link{plot}}:
|
|
|
24 |
\code{"p"} for points, \code{"l"} for lines,
|
|
|
25 |
\code{"o"} for overplotted points and lines,
|
|
|
26 |
\code{"b"}, \code{"c"}) for (empty if \code{"c"}) points joined by lines,
|
|
|
27 |
\code{"s"} and \code{"S"} for stair steps and
|
|
|
28 |
\code{"h"} for histogram-like vertical lines. Finally,
|
|
|
29 |
\code{"n"} does not produce any points or lines.}
|
|
|
30 |
\item{xlim}{the x limits (min,max) of the plot.}
|
|
|
31 |
\item{ylim}{the y limits of the plot.}
|
|
|
32 |
\item{log}{a character string which contains \code{"x"} if the x axis
|
|
|
33 |
is to be logarithmic, \code{"y"} if the y axis is to be logarithmic
|
|
|
34 |
and \code{"xy"} or \code{"yx"} if both axes are to be logarithmic.}
|
|
|
35 |
|
|
|
36 |
\item{main}{a main title for the plot.}
|
|
|
37 |
\item{sub}{a sub title for the plot.}
|
|
|
38 |
\item{xlab}{a label for the x axis.}
|
|
|
39 |
\item{ylab}{a label for the y axis.}
|
|
|
40 |
|
|
|
41 |
\item{ann}{a logical value indicating whether the default annotation
|
|
|
42 |
(title and x and y axis labels) should appear on the plot.}
|
|
|
43 |
\item{axes}{a logical value indicating whether axes should be drawn on
|
|
|
44 |
the plot.}
|
|
|
45 |
\item{frame.plot}{a logical indicating whether a box should be drawn
|
|
|
46 |
around the plot.}
|
|
|
47 |
|
|
|
48 |
\item{panel.first}{an expression to be evaluated after the plot axes
|
|
|
49 |
are set up but before any plotting takes place. This can be useful
|
|
|
50 |
for drawing background grids or scatterplot smooths.}
|
|
|
51 |
\item{panel.last}{an expression to be evaluated after plotting has
|
|
|
52 |
taken place.}
|
|
|
53 |
|
|
|
54 |
\item{col}{The colors for lines and points. Multiple colors can be
|
|
|
55 |
specified so that each point can be given its own color. If there
|
|
|
56 |
are fewer colors than points they are recycled in the standard
|
|
|
57 |
fashion. Lines will all be plotted in the first colour specified.}
|
|
|
58 |
\item{bg}{background color for open plot symbols, see
|
|
|
59 |
\code{\link{points}}.}
|
|
|
60 |
\item{pch}{a vector of plotting characters or symbols: see \code{\link{points}}.}
|
|
|
61 |
\item{cex}{a numerical vector giving the amount by which plotting text
|
|
|
62 |
and symbols should be scaled relative to the default.}
|
|
|
63 |
\item{lty}{the line type, see \code{\link{par}}.}
|
|
|
64 |
\item{lab}{the specification for the (approximate) numbers of tick
|
|
|
65 |
marks on the x and y axes.}
|
|
|
66 |
\item{lwd}{the line width \bold{not yet supported for postscript}.}
|
|
|
67 |
\item{asp}{the \eqn{y/x} aspect ratio, see \code{\link{plot.window}}.}
|
|
|
68 |
\item{\dots}{graphical parameters as in \code{\link{par}} may also be
|
|
|
69 |
passed as arguments.}
|
|
|
70 |
}
|
|
|
71 |
\references{
|
|
|
72 |
Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988)
|
|
|
73 |
\emph{The New S Language}.
|
|
|
74 |
Wadsworth \& Brooks/Cole.
|
|
|
75 |
|
|
|
76 |
Cleveland, W. S. (1985)
|
|
|
77 |
\emph{The Elements of Graphing Data.}
|
|
|
78 |
Monterey, CA: Wadsworth.
|
|
|
79 |
}
|
|
|
80 |
\seealso{
|
|
|
81 |
\code{\link{plot}}, \code{\link{plot.window}}, \code{\link{xy.coords}}.
|
|
|
82 |
}
|
|
|
83 |
\examples{
|
|
|
84 |
data(cars)
|
|
|
85 |
Speed <- cars$speed
|
|
|
86 |
Distance <- cars$dist
|
|
|
87 |
plot(Speed, Distance, panel.first = grid(8,8),
|
|
|
88 |
pch = 0, cex = 1.2, col = "blue")
|
|
|
89 |
plot(Speed, Distance,
|
|
|
90 |
panel.first = lines(lowess(Speed, Distance), lty = "dashed"),
|
|
|
91 |
pch = 0, cex = 1.2, col = "blue")
|
|
|
92 |
|
|
|
93 |
## Show the different plot types
|
|
|
94 |
x <- 0:12
|
|
|
95 |
y <- sin(pi/5 * x)
|
|
|
96 |
op <- par(mfrow = c(3,3), mar = .1+ c(2,2,3,1))
|
|
|
97 |
for (tp in c("p","l","b", "c","o","h", "s","S","n")) {
|
|
|
98 |
plot(y ~ x, type = tp,
|
|
|
99 |
main = paste("plot(*, type = \"",tp,"\")",sep=""))
|
|
|
100 |
if(tp == "S") {
|
|
|
101 |
lines(x,y, type = "s", col = "red", lty = 2)
|
|
|
102 |
mtext("lines(*, type = \"s\", ...)", col = "red", cex=.8)
|
|
|
103 |
}
|
|
|
104 |
}
|
|
|
105 |
par(op)
|
|
|
106 |
|
|
|
107 |
##--- Log-Log Plot with custom axes
|
|
|
108 |
lx <- seq(1,5, length=41)
|
|
|
109 |
yl <- expression(e^{-frac(1,2) * {log[10](x)}^2})
|
|
|
110 |
y <- exp(-.5*lx^2)
|
|
|
111 |
op <- par(mfrow=c(2,1), mar=par("mar")+c(0,1,0,0))
|
|
|
112 |
plot(10^lx, y, log="xy", type="l", col="purple",
|
|
|
113 |
main="Log-Log plot", ylab=yl, xlab="x")
|
|
|
114 |
plot(10^lx, y, log="xy", type="o", pch='.', col="forestgreen",
|
|
|
115 |
main="Log-Log plot with custom axes", ylab=yl, xlab="x",
|
|
|
116 |
axes = FALSE, frame.plot = TRUE)
|
|
|
117 |
axis(1, at = my.at <- 10^(1:5), labels = formatC(my.at, format="fg"))
|
|
|
118 |
at.y <- 10^(-5:-1)
|
|
|
119 |
axis(2, at = at.y, labels = formatC(at.y, format="fg"), col.axis="red")
|
|
|
120 |
par(op)
|
|
|
121 |
}
|
|
|
122 |
\keyword{hplot}
|