Learn R Programming

berryFunctions (version 1.6)

logAxis: label logarithmic axes

Description

shortcut to calling logVals, axis and abline

Usage

logAxis(side=1, log=NULL, lcol="grey", lty=1, lwd=1, expr, las=1, from=-7,
to=7, Range=range(from, to), base=c(1,2,5), big.mark="'", decimal.mark=".",
scientific=FALSE, ...)

Arguments

side
Which axis is to be labeled?. DEFAULT: 1
log
Is the axis logarithmic by plot(log="x")? internal DEFAULT: par("xlog") or "ylog". DEFAULT: NULL
lcol
Color of gridlines drawn in the graph with abline, NA to suppress. DEFAULT: "grey"
lty, lwd
Type of gridlines. DEFAULT: 1
expr
Expression drawing over the ablines, like (points(x,y). Can be code within {braces}.
las
LabelAxisStyle for the orientation of the labels. DEFAULT: 1
from
Lower exponent OR vector with data, as in logVals. DEFAULT: -7
to
High end exponent. DEFAULT: 7
Range
Override from and to as range. DEFAULT: range(from, to)
base
Bases to be used, eg. c(1,2,5) or 1. DEFAULT: c(1,2,5)
big.mark
Symbol separating thousands, eg. space, comma, dot, etc. see "format" and "prettyNum". DEFAULT: "'"
decimal.mark
Character separating comma values, see "format" and "prettyNum". DEFAULT: "."
scientific
See format. DEFAULT: FALSE
...
further arguments passed to axis, like lwd, col.ticks, hadj, lty, ...

Value

  • An invisible list with
  • valsValues for lines and label positions
  • labsFormatted values for labels
  • allValues for lines

See Also

logVals, log10

Examples

Run this code
x <- 10^runif(200, -1, 2)
plot(x, 1:200, xaxt="n", log="x")
logAxis(base=1)
# overplot vertical lines:
logAxis(expr=points(x, 1:200), base=c(1,2,5), col=2 )

# plots where log="x" is not possible:
hist(log10(x), breaks=20, col.axis="grey", main="")
logAxis(side=3, expr=hist(log10(x),breaks=20,add=TRUE, col=3))

Run the code above in your browser using DataLab