| 1 |
\name{axTexpr} |
| 2 |
\alias{axTexpr} |
| 3 |
\title{Axis Ticks Expressions in Nice 10 ** k Form} |
| 4 |
\description{ |
| 5 |
Produce nice \eqn{a \times 10^k}{a * 10^k} expressions for |
| 6 |
\code{\link{axis}} labeling instead of the scientific notation |
| 7 |
\code{"a E<k>"}. |
| 8 |
|
| 9 |
} |
| 10 |
\usage{ |
| 11 |
axTexpr(side, at = axTicks(side, axp = axp, usr = usr, log = log), |
| 12 |
axp = NULL, usr = NULL, log = NULL, |
| 13 |
drop.1 = FALSE) |
| 14 |
} |
| 15 |
\arguments{ |
| 16 |
\item{side}{integer in 1:4 specifying the axis side, as for |
| 17 |
\code{\link{axis}}.} |
| 18 |
\item{at}{numeric vector; with identical default as in |
| 19 |
\code{\link{axTicks}()}.} |
| 20 |
\item{axp, usr, log}{as for \code{\link{axTicks}()}.} |
| 21 |
\item{drop.1}{logical indicating if \eqn{1 \times}{1 *} should be |
| 22 |
dropped from the resulting expressions.} |
| 23 |
} |
| 24 |
\details{ |
| 25 |
This is just a utility with the same arguments as |
| 26 |
\code{\link{axTicks}}, a wrapper \code{\link{pretty10exp}(at, *)}. |
| 27 |
} |
| 28 |
\value{ |
| 29 |
an expression of the same length as \code{x}, with elements of the |
| 30 |
form \code{a \%*\% 10 ^ k}. |
| 31 |
} |
| 32 |
\author{Martin Maechler} |
| 33 |
\seealso{\code{\link{pretty10exp}}; |
| 34 |
\code{\link{eaxis}}, \code{\link{axis}}, \code{\link{axTicks}}. |
| 35 |
} |
| 36 |
\examples{ |
| 37 |
x <- 1e7*(-10:50) |
| 38 |
y <- dnorm(x, m=10e7, s=20e7) |
| 39 |
plot(x,y)## not really nice, the following is better: |
| 40 |
|
| 41 |
## For horizontal y-axis labels, need more space: |
| 42 |
op <- par(mar= .1+ c(5,5,4,1)) |
| 43 |
plot(x,y, axes= FALSE, frame=TRUE) |
| 44 |
aX <- axTicks(1); axis(1, at=aX, label= axTexpr(1, aX)) |
| 45 |
## horizontal labels on y-axis: |
| 46 |
aY <- axTicks(2); axis(2, at=aY, label= axTexpr(2, aY), las=2) |
| 47 |
par(op) |
| 48 |
|
| 49 |
### -- only 'x' and using log-scale there: |
| 50 |
plot(x,y, xaxt= "n", log = "x") |
| 51 |
aX <- axTicks(1); axis(1, at=aX, label= axTexpr(1, aX)) |
| 52 |
|
| 53 |
## Now an "engineer's version" ( more ticks; only label "10 ^ k" ) : |
| 54 |
|
| 55 |
axp <- par("xaxp") #-> powers of 10 *inside* 'usr' |
| 56 |
axp[3] <- 1 # such that only 10^. are labeled |
| 57 |
aX <- axTicks(1, axp = axp) |
| 58 |
xu <- 10 ^ par("usr")[1:2] |
| 59 |
e10 <- c(-1,1) + round(log10(axp[1:2])) ## exponents of 10 *outside* 'usr' |
| 60 |
v <- c(outer(1:9, e10[1]:e10[2], function(x,E) x * 10 ^ E)) |
| 61 |
v <- v[xu[1] <= v & v <= xu[2]] |
| 62 |
|
| 63 |
plot(x,y, xaxt= "n", log = "x", main = "engineer's version of x - axis") |
| 64 |
axis(1, at = aX, label = axTexpr(1, aX, drop.1=TRUE)) # 'default' |
| 65 |
axis(1, at = v, label = FALSE, tcl = 2/3 * par("tcl")) |
| 66 |
} |
| 67 |
\keyword{dplot} |