Skip to content

Commit 53953c0

Browse files
author
maechler
committed
improve axisTicks(*, log = TRUE) docu
git-svn-id: https://svn.r-project.org/R/trunk@87344 00db46b3-68df-0310-9c12-caf00c1e9a41
1 parent 808c402 commit 53953c0

File tree

3 files changed

+31
-10
lines changed

3 files changed

+31
-10
lines changed

doc/NEWS.Rd

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,9 @@
358358
integer to double, analogously with \code{seq.default()},
359359
\code{seq.int()} and \code{seq.POSIXt()}, resolving a \emph{modified}
360360
\PR{18782}.
361+
362+
\item \code{axisTicks(usr, ...)} documentation clarification for
363+
\code{log=TRUE}, fixing bug \PR{18821} thanks to Duncan Murdoch.
361364
}
362365
}
363366
}

src/library/grDevices/man/axisTicks.Rd

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
% File src/library/grDevices/man/axisTicks.Rd
22
% Part of the R package, https://www.R-project.org
3-
% Copyright 2011-2020 R Core Team
3+
% Copyright 2011-2024 R Core Team
44
% Distributed under GPL 2 or later
55

66
\name{axisTicks}
@@ -18,7 +18,9 @@ axisTicks(usr, log, axp = NULL, nint = 5)
1818
}
1919
\arguments{
2020
\item{usr}{numeric vector of length 2, with \code{c(min, max)} axis
21-
extents.}
21+
extents. Corresponds to traditional \pkg{graphics}'
22+
\code{\link[graphics]{par}("usr")}, and hence for \code{log = TRUE}
23+
needs to use \code{\link{log10}()} transformed coordinates.}
2224
\item{log}{logical indicating if a log scale is (thought to be) in
2325
use.}
2426
\item{axp}{numeric vector of length 3, \code{c(mi, ma, n.)}, with
@@ -46,7 +48,8 @@ axisTicks(usr, log, axp = NULL, nint = 5)
4648
}
4749
\value{
4850
\code{axisTicks()} returns a numeric vector of potential axis tick
49-
locations, of length approximately \code{nint+1}.
51+
locations in case of \code{log=TRUE} in the original scale, of length
52+
approximately \code{nint+1}.
5053
5154
\code{.axisPars()} returns a \code{\link{list}} with components
5255
\item{axp}{numeric vector of length 2, \code{c(min., max.)}, of pretty
@@ -73,11 +76,18 @@ aX(2, print(ya <- axisTicks(pu[3:4], log = FALSE))) # y axis
7376

7477
axisTicks(pu[3:4], log = FALSE, nint = 10)
7578

76-
plot(10*(0:10), log = "y"); (pu <- par("usr"))
77-
aX(2, print(ya <- axisTicks(pu[3:4], log = TRUE))) # y axis
79+
80+
## -------------------- Log Scale --------------------------------
81+
x <- c(10, 1000)
82+
# _____
83+
axisTicks(log10(x), log = TRUE) # 10 20 50 .... 1000
84+
85+
plot(10*(0:10), log = "y"); (pu <- par("usr")) # ... ... 0.96 2.04
86+
aX(2, print(ya <- axisTicks(pu[3:4], log = TRUE))) # 10 20 50 100 (y axis)
7887

7988
plot(2^(0:9), log = "y"); (pu <- par("usr"))
8089
aX(2, print(ya <- axisTicks(pu[3:4], log = TRUE))) # y axis
81-
90+
## 'usr' corresponds to log10(<range>) :
91+
stopifnot(ya == axisTicks(log10(c(1, 512)), log=TRUE))
8292
}
8393
\keyword{dplot}

tests/Examples/grDevices-Ex.Rout.save

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
R Under development (unstable) (2024-08-29 r87078) -- "Unsuffered Consequences"
2+
R Under development (unstable) (2024-11-18 r87340) -- "Unsuffered Consequences"
33
Copyright (C) 2024 The R Foundation for Statistical Computing
44
Platform: x86_64-pc-linux-gnu
55

@@ -388,18 +388,26 @@ $allowed
388388
> axisTicks(pu[3:4], log = FALSE, nint = 10)
389389
[1] 0 10 20 30 40 50 60 70 80 90 100
390390
>
391-
> plot(10*(0:10), log = "y"); (pu <- par("usr"))
391+
>
392+
> ## -------------------- Log Scale --------------------------------
393+
> x <- c(10, 1000)
394+
> # _____
395+
> axisTicks(log10(x), log = TRUE) # 10 20 50 .... 1000
396+
[1] 10 20 50 100 200 500 1000
397+
>
398+
> plot(10*(0:10), log = "y"); (pu <- par("usr")) # ... ... 0.96 2.04
392399
Warning in xy.coords(x, y, xlabel, ylabel, log) :
393400
1 y value <= 0 omitted from logarithmic plot
394401
[1] 0.60 11.40 0.96 2.04
395-
> aX(2, print(ya <- axisTicks(pu[3:4], log = TRUE))) # y axis
402+
> aX(2, print(ya <- axisTicks(pu[3:4], log = TRUE))) # 10 20 50 100 (y axis)
396403
[1] 10 20 50 100
397404
>
398405
> plot(2^(0:9), log = "y"); (pu <- par("usr"))
399406
[1] 0.6400000 10.3600000 -0.1083708 2.8176408
400407
> aX(2, print(ya <- axisTicks(pu[3:4], log = TRUE))) # y axis
401408
[1] 1 2 5 10 20 50 100 200 500
402-
>
409+
> ## 'usr' corresponds to log10(<range>) :
410+
> stopifnot(ya == axisTicks(log10(c(1, 512)), log=TRUE))
403411
>
404412
>
405413
>

0 commit comments

Comments
 (0)