| 42333 |
ripley |
1 |
% File src/library/graphics/man/plot.window.Rd
|
| 68948 |
ripley |
2 |
% Part of the R package, https://www.R-project.org
|
| 65043 |
ripley |
3 |
% Copyright 1995-2014 R Core Team
|
| 42333 |
ripley |
4 |
% Distributed under GPL 2 or later
|
|
|
5 |
|
| 27442 |
ripley |
6 |
\name{plot.window}
|
| 56186 |
murdoch |
7 |
\alias{plot.window}
|
| 48757 |
ripley |
8 |
\alias{xlim}
|
|
|
9 |
\alias{ylim}
|
| 38888 |
ripley |
10 |
\alias{asp}
|
|
|
11 |
\concept{aspect ratio}
|
| 45585 |
murdoch |
12 |
\concept{log scale}
|
|
|
13 |
\concept{axis range}
|
| 27442 |
ripley |
14 |
\title{Set up World Coordinates for Graphics Window}
|
|
|
15 |
\description{
|
|
|
16 |
This function sets up the world coordinate system for a graphics
|
|
|
17 |
window. It is called by higher level functions such as
|
|
|
18 |
\code{\link{plot.default}} (\emph{after} \code{\link{plot.new}}).
|
|
|
19 |
}
|
|
|
20 |
\usage{
|
|
|
21 |
plot.window(xlim, ylim, log = "", asp = NA, \dots)
|
|
|
22 |
}
|
|
|
23 |
\arguments{
|
| 39607 |
ripley |
24 |
\item{xlim, ylim}{numeric vectors of length 2, giving the x and y
|
|
|
25 |
coordinates ranges.}
|
| 27442 |
ripley |
26 |
\item{log}{character; indicating which axes should be in log scale.}
|
| 56108 |
ripley |
27 |
\item{asp}{numeric, giving the \bold{asp}ect ratio y/x,
|
|
|
28 |
see \sQuote{Details}.}
|
| 56113 |
ripley |
29 |
\item{\dots}{further \link{graphical parameters} as in \code{\link{par}}.
|
| 36235 |
ripley |
30 |
The relevant ones are \code{xaxs}, \code{yaxs} and \code{lab}.
|
| 36209 |
ripley |
31 |
}
|
| 27442 |
ripley |
32 |
}
|
|
|
33 |
\details{
|
| 42608 |
maechler |
34 |
\describe{
|
|
|
35 |
\item{asp:}{
|
|
|
36 |
If \code{asp} is a finite positive value then the window is
|
|
|
37 |
set up so that one data unit in the x direction is equal in length to
|
|
|
38 |
\code{asp} \eqn{\times}{*} one data unit in the y direction.
|
| 27442 |
ripley |
39 |
|
| 42608 |
maechler |
40 |
Note that in this case, \code{\link{par}("usr")} is no longer
|
|
|
41 |
determined by, e.g., \code{par("xaxs")}, but rather by \code{asp} and
|
| 65043 |
ripley |
42 |
the device's aspect ratio. (See what happens if you interactively
|
| 42608 |
maechler |
43 |
resize the plot device after running the example below!)
|
| 27442 |
ripley |
44 |
|
| 42608 |
maechler |
45 |
The special case \code{asp == 1} produces plots where distances
|
|
|
46 |
between points are represented accurately on screen. Values with
|
|
|
47 |
\code{asp > 1} can be used to produce more accurate maps when using
|
|
|
48 |
latitude and longitude.
|
|
|
49 |
}}
|
|
|
50 |
|
| 56108 |
ripley |
51 |
Note that the coordinate ranges will be extended by 4\% if the
|
| 56113 |
ripley |
52 |
appropriate \link{graphical parameter} \code{xaxs} or \code{yaxs} has value
|
| 65043 |
ripley |
53 |
\code{"r"} (which is the default).
|
| 56108 |
ripley |
54 |
|
| 39607 |
ripley |
55 |
To reverse an axis, use \code{xlim} or \code{ylim} of the form
|
|
|
56 |
\code{c(hi, lo)}.
|
| 42608 |
maechler |
57 |
|
| 27601 |
ripley |
58 |
The function attempts to produce a plausible set of scales if one or
|
|
|
59 |
both of \code{xlim} and \code{ylim} is of length one or the two values
|
|
|
60 |
given are identical, but it is better to avoid that case.
|
|
|
61 |
|
| 56108 |
ripley |
62 |
Usually, one should rather use the higher-level functions such as
|
| 27442 |
ripley |
63 |
\code{\link{plot}}, \code{\link{hist}}, \code{\link{image}}, \dots,
|
|
|
64 |
instead and refer to their help pages for explanation of the
|
|
|
65 |
arguments.
|
| 36209 |
ripley |
66 |
|
|
|
67 |
A side-effect of the call is to set up the \code{usr}, \code{xaxp} and
|
| 56113 |
ripley |
68 |
\code{yaxp} \link{graphical parameters}. (It is for the latter two that
|
| 36209 |
ripley |
69 |
\code{lab} is used.)
|
| 27442 |
ripley |
70 |
}
|
|
|
71 |
\seealso{
|
|
|
72 |
\code{\link{xy.coords}},
|
|
|
73 |
\code{\link{plot.xy}},
|
|
|
74 |
\code{\link{plot.default}}.
|
| 56108 |
ripley |
75 |
|
|
|
76 |
\code{\link{par}} for the graphical parameters mentioned.
|
| 27442 |
ripley |
77 |
}
|
|
|
78 |
\examples{
|
|
|
79 |
##--- An example for the use of 'asp' :
|
| 30448 |
ripley |
80 |
require(stats) # normally loaded
|
| 27442 |
ripley |
81 |
loc <- cmdscale(eurodist)
|
|
|
82 |
rx <- range(x <- loc[,1])
|
|
|
83 |
ry <- range(y <- -loc[,2])
|
| 61153 |
ripley |
84 |
plot(x, y, type = "n", asp = 1, xlab = "", ylab = "")
|
| 27442 |
ripley |
85 |
abline(h = pretty(rx, 10), v = pretty(ry, 10), col = "lightgray")
|
| 61153 |
ripley |
86 |
text(x, y, labels(eurodist), cex = 0.8)
|
| 27442 |
ripley |
87 |
}
|
|
|
88 |
\keyword{aplot}
|