Learn R Programming

stressaddition (version 3.1.0)

log10_ticks: Logarithmic axis tick marks

Description

Calculate the positions and labels of major and minor tick marks for a base 10 logarithmic axis.

Usage

log10_ticks(x, label_zero = TRUE)

Arguments

x

A vector of axis values. Can be arbitrarily long but only the minimum and maximum are necessary.

label_zero

Whether or not to replace the smallest major label with "0". This defaults to TRUE and is useful for some types of plots used to display concentration-response data where the leftmost data point represents the control.

Value

A list with the positions and labels of the major and minor tick marks. The labels are formatted without trailing zeros using formatC(labels, format = "fg").

Examples

Run this code
# NOT RUN {
x <- c(0.01, 0.2, 3, 10, 50)
plot(x, c(5, 4, 2.5, 1, 0), xaxt = "n", log = "x")
ticks <- log10_ticks(x)
axis(1, at = ticks$major, labels = ticks$major_labels)
axis(1, at = ticks$minor, labels = FALSE, tcl = -0.25)

# }

Run the code above in your browser using DataLab