logticks: Add proper logarithm ticks to a plot axis.

View source: R/utilities.R

logticksR Documentation

Add proper logarithm ticks to a plot axis.

Description

Add proper logarithm ticks to a plot axis.

Usage

logticks(
  ax = 1,
  n.minor = 9,
  t.lims,
  t.ratio = 0.5,
  major.ticks = NULL,
  base = c("ten", "ln", "two"),
  ticks.only = FALSE,
  ...
)

log_ticks(...)

log2_ticks(...)

log10_ticks(...)

Arguments

ax

numeric; the axis number to add tick-marks to

n.minor

numeric; the number of minor ticks to display

t.lims

numeric; the upper and lower tick limits (in log space)

t.ratio

numeric; the ratio of minor to major tick lengths.

major.ticks

numeric; the axis limits.

base

numeric; the base of the logarithm (somewhat experimental)

ticks.only

logical; on the axis

...

additional parameters passed to the axis call for the major ticks.

Details

This uses pretty with n==5, and assumes that the data along the axis ax has already been transformed into its logarithm. Only integer exponents are labeled.

The functions log_ticks, log2_ticks, and log10_ticks are wrapper functions.

Set the axt parameter (e.g. xaxt) to 'n' in the original plot command to prevent adding default tick marks.

Author(s)

A. J. Barbour <andy.barbour@gmail.com>

References

This was modified from a post on StackOverflow: https://stackoverflow.com/questions/6955440/displaying-minor-logarithmic-ticks-in-x-axis-in-r

See Also

Other PlotUtilities: wrsp-methods

Examples

x <- 10^(0:8)
y <- 1:9

plot(log10(x),y,xaxt="n",xlab="x",xlim=c(0,9))
logticks()
logticks(ax=3, ticks.only=TRUE)

par(tcl=0.5) # have tick marks show up on inside instead
plot(log10(x),y,xaxt="n",xlab="x",xlim=c(0,9))
logticks()
logticks(ax=3, ticks.only=TRUE)

abarbour/kitagawa documentation built on Feb. 1, 2024, 2:49 p.m.