| Line 1... |
Line 1... |
| 1 |
% File src/library/graphics/man/plotdefault.Rd
|
1 |
% File src/library/graphics/man/plotdefault.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-2018 R Core Team
|
3 |
% Copyright 1995-2025 R Core Team
|
| 4 |
% Distributed under GPL 2 or later
|
4 |
% Distributed under GPL 2 or later
|
| 5 |
|
5 |
|
| 6 |
\name{plot.default}
|
6 |
\name{plot.default}
|
| 7 |
\alias{plot.default}
|
7 |
\alias{plot.default}
|
| 8 |
\alias{plot}
|
8 |
\alias{plot}
|
| Line 11... |
Line 11... |
| 11 |
Draw a scatter plot with decorations such as axes and titles
|
11 |
Draw a scatter plot with decorations such as axes and titles
|
| 12 |
in the active graphics window.
|
12 |
in the active graphics window.
|
| 13 |
}
|
13 |
}
|
| 14 |
\usage{
|
14 |
\usage{
|
| 15 |
\method{plot}{default}(x, y = NULL, type = "p", xlim = NULL, ylim = NULL,
|
15 |
\method{plot}{default}(x, y = NULL, type = "p", xlim = NULL, ylim = NULL,
|
| 16 |
log = "", main = NULL, sub = NULL, xlab = NULL, ylab = NULL,
|
16 |
log = "", lim2 = FALSE, main = NULL, sub = NULL, xlab = NULL, ylab = NULL,
|
| 17 |
ann = par("ann"), axes = TRUE, frame.plot = axes,
|
17 |
ann = par("ann"), axes = TRUE, frame.plot = axes,
|
| 18 |
panel.first = NULL, panel.last = NULL, asp = NA,
|
18 |
panel.first = NULL, panel.last = NULL, asp = NA,
|
| 19 |
xgap.axis = NA, ygap.axis = NA,
|
19 |
xgap.axis = NA, ygap.axis = NA,
|
| 20 |
\dots)
|
20 |
\dots)
|
| 21 |
}
|
21 |
}
|
| Line 37... |
Line 37... |
| 37 |
\item{xlim}{the x limits (x1, x2) of the plot. Note that \code{x1 > x2}
|
37 |
\item{xlim}{the x limits (x1, x2) of the plot. Note that \code{x1 > x2}
|
| 38 |
is allowed and leads to a \sQuote{reversed axis}.
|
38 |
is allowed and leads to a \sQuote{reversed axis}.
|
| 39 |
|
39 |
|
| 40 |
The default value, \code{NULL}, indicates that the range of the
|
40 |
The default value, \code{NULL}, indicates that the range of the
|
| 41 |
\link{finite} values to be plotted should be used.}
|
41 |
\link{finite} values to be plotted should be used.}
|
| 42 |
\item{ylim}{the y limits of the plot.}
|
42 |
\item{ylim}{the y limits of the plot; see \code{xlim} for default and details.}
|
| 43 |
\item{log}{a character string which contains \code{"x"} if the x axis
|
43 |
\item{log}{a character string which contains \code{"x"} if the x axis
|
| 44 |
is to be logarithmic, \code{"y"} if the y axis is to be logarithmic
|
44 |
is to be logarithmic, \code{"y"} if the y axis is to be logarithmic
|
| 45 |
and \code{"xy"} or \code{"yx"} if both axes are to be logarithmic.}
|
45 |
and \code{"xy"} or \code{"yx"} if both axes are to be logarithmic.}
|
| 46 |
|
- |
|
| - |
|
46 |
\item{lim2}{logical, relevant only when at least one of \code{xlim} or
|
| - |
|
47 |
\code{ylim} are \code{NULL} and hence corresponding axis limits are
|
| - |
|
48 |
computed from \code{\link{range}(<x/y-coord>[<finite-coord>])}.
|
| - |
|
49 |
When true, \emph{both} x- and y-values need to be finite to be used in
|
| - |
|
50 |
the \code{range(.)} computation.}
|
| 47 |
\item{main}{a main title for the plot, see also \code{\link{title}}.}
|
51 |
\item{main}{a main title for the plot, see also \code{\link{title}}.}
|
| 48 |
\item{sub}{a subtitle for the plot.}
|
52 |
\item{sub}{a subtitle for the plot.}
|
| 49 |
\item{xlab}{a label for the x axis, defaults to a description of \code{x}.}
|
53 |
\item{xlab}{a label for the x axis, defaults to a description of \code{x}.}
|
| 50 |
\item{ylab}{a label for the y axis, defaults to a description of \code{y}.}
|
54 |
\item{ylab}{a label for the y axis, defaults to a description of \code{y}.}
|
| 51 |
|
55 |
|
| Line 148... |
Line 152... |
| 148 |
mtext("lines(*, type = \"s\", ...)", col = "red", cex = 0.8)
|
152 |
mtext("lines(*, type = \"s\", ...)", col = "red", cex = 0.8)
|
| 149 |
}
|
153 |
}
|
| 150 |
}
|
154 |
}
|
| 151 |
par(op)
|
155 |
par(op)
|
| 152 |
|
156 |
|
| - |
|
157 |
## Log Plots -- default xlim / ylim from range(<finite>)
|
| - |
|
158 |
set.seed(2); noise <- rnorm(100)/100; xe <- sort(rexp(100, 8))
|
| - |
|
159 |
x <- sort(xe + noise); y <- exp(-x^2 + (x < 0)*10)*sin(pi*x)
|
| - |
|
160 |
str(data.frame(x,y))
|
| - |
|
161 |
plot(y ~ x) # (2 outliers, x < 0)
|
| - |
|
162 |
plot(y ~ x, log="x") # --> Warning: 2 x values <= 0 omitted from log..plot
|
| - |
|
163 |
# still same y-axis limits [~ -570, 0 ]
|
| - |
|
164 |
plot(y ~ x, log="x", lim2 = TRUE) # still Warning, but
|
| - |
|
165 |
# nice - reasonable y-axis [0, 0.8]
|
| - |
|
166 |
|
| 153 |
##--- Log-Log Plot with custom axes
|
167 |
##--- Log-Log Plot with custom axes
|
| 154 |
lx <- seq(1, 5, length.out = 41)
|
168 |
lx <- seq(1, 5, length.out = 41)
|
| 155 |
yl <- expression(e^{-frac(1,2) * {log[10](x)}^2})
|
169 |
yl <- expression(e^{-frac(1,2) * {log[10](x)}^2})
|
| 156 |
y <- exp(-.5*lx^2)
|
170 |
y <- exp(-.5*lx^2)
|
| 157 |
op <- par(mfrow = c(2,1), mar = par("mar")-c(1,0,2,0), mgp = c(2, .7, 0))
|
171 |
op <- par(mfrow = c(2,1), mar = par("mar")-c(1,0,2,0), mgp = c(2, .7, 0))
|