Compute Pretty Axis Tick Scales

Compute pretty axis scales and tick mark locations, the same way as traditional Rgraphics do it. This is interesting particularly for log scale axes.

axisTicks(usr, log, axp = NULL, nint = 5)
 .axisPars(usr, log = FALSE, nintLog = 5)
numeric vector of length 2, with c(min, max) axis extents.
logical indicating if a log scale is (thought to be) in use.
numeric vector of length 3, c(mi, ma, n.), with identical meaning to par("?axp") (where ? is x or y), namely pretty axis extents, and an integer code n..
nint, nintLog
positive integer value indicating (approximately) the desired number of intervals. nintLog is used only for the case log = TRUE.

axisTicks(usr, *) calls .axisPars(usr, ..) when axp is missing (or NULL).


  • axisTicks() returns a numeric vector of potential axis tick locations, of length approximately nint+1.

    .axisPars() returns a list with components

  • axpnumeric vector of length 2, c(min., max.), of pretty axis extents.
  • ninteger (code), with the same meaning as par("?axp")[3].

See Also

axTicks; axis, and par (from the graphics package).

  • axisTicks
  • .axisPars
library(grDevices) ##--- Demonstrating correspondence between graphics' ##--- axis() and the graphics-engine agnostic axisTicks() : require("graphics") plot(10*(0:10)); (pu <- par("usr")) aX <- function(side, at, ...) axis(side, at = at, labels = FALSE, lwd.ticks = 2, col.ticks = 2, tck = 0.05, ...) aX(1, print(xa <- axisTicks(pu[1:2], log = FALSE))) # x axis aX(2, print(ya <- axisTicks(pu[3:4], log = FALSE))) # y axis axisTicks(pu[3:4], log = FALSE, n = 10) plot(10*(0:10), log = "y"); (pu <- par("usr")) aX(2, print(ya <- axisTicks(pu[3:4], log = TRUE))) # y axis plot(2^(0:9), log = "y"); (pu <- par("usr")) aX(2, print(ya <- axisTicks(pu[3:4], log = TRUE))) # y axis
Documentation reproduced from package grDevices, version 3.3, License: Part of R 3.3

Community examples

Looks like there are no examples yet.