laxis: Add a logarithmic axis

View source: R/plot_extra.R

laxisR Documentation

Add a logarithmic axis

Description

Draw minor ticks on a log scale axis.

Usage

laxis(
  side = 1L,
  nticks = 5L,
  labels = TRUE,
  digits = 0L,
  base = 10,
  limit = base^3,
  simplify = TRUE,
  ...
)

Arguments

side

an integer specifying which side of the plot the axis is to be drawn on: 1=below, 2=left, 3=above, 4=right

nticks

number of minor ticks between each pair of major ticks

labels

logical; if TRUE, major ticks will be labeled using pretty_sci

digits, base, limit, simplify

additional arguments passed to pretty_sci

...

additional graphical parameters passed to par

Value

A list with elements at.major and at.minor giving the points at which tick marks were drawn for the major and minor axes, respectively.

See Also

pretty_sci; axTexpr; axis

Examples

x <- 1:10
y <- function(base) base ^ x
op <- par(mar = c(3,5,3,5), las = 1)
plot(x, log(y(2), 2), ann = FALSE, axes = FALSE)
laxis(2, base = 2, limit = -1)

par(new = TRUE)
plot(x, y(10), log = 'y', axes = FALSE, ann = FALSE)
laxis(4, nticks = 10, tcl = .5, col.axis = 2)

par(new = TRUE)
plot(x, x, log = 'x', axes = FALSE, ann = FALSE, xpd = NA)
laxis(1, nticks = 10, tcl = -1, col.axis = 1, lwd = 2)
abline(v = x)

par(op)


raredd/plotr documentation built on Nov. 19, 2023, 4:09 a.m.