logticks: Add proper logarithm ticks to a plot axis.

Description Usage Arguments Details Author(s) References See Also Examples

View source: R/utilities.R

Description

Add proper logarithm ticks to a plot axis.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
logticks(
  ax = 1,
  n.minor = 9,
  t.lims,
  t.ratio = 0.5,
  major.ticks = NULL,
  base = c("ten", "ln", "two"),
  ...
)

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)

...

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: http://stackoverflow.com/questions/6955440/displaying-minor-logarithmic-ticks-in-x-axis-in-r

See Also

Other PlotUtilities: wrsp-methods

Examples

1
2
3
4
x <- 10^(0:8)
y <- 1:9
plot(log10(x),y,xaxt="n",xlab="x",xlim=c(0,9))
logticks()

Example output

Loading required package: kelvin
Loaded kelvin (2.0.0) -- Solutions to the Kelvin differential equation
Loaded kitagawa (2.1.0) -- Spectral response of water wells

kitagawa documentation built on July 2, 2020, 1:47 a.m.