logAxis(
side = 1,
log = NULL,
lcol = "grey",
lty = 1,
lwd = 1,
labels = NULL,
allticks = FALSE,
allargs = NULL,
expr,
las = 1,
from,
to,
Range,
base = NA,
big.mark = "'",
decimal.mark = ".",
scientific = FALSE,
exponent = 5,
expobase1 = FALSE,
allbase = 1:9,
box = TRUE,
...
)
An invisible list with
Values for lines and label positions
Formatted values for labels
Values for lines
Which axis
are to be labeled? Can be a vector within 1:4
. DEFAULT: 1
Is the axis logarithmic by plot(log="x")? internal DEFAULT: par("xlog")
or "ylog". DEFAULT: NULL
Color of gridlines drawn in the graph with abline
, NA to suppress. DEFAULT: "grey"
Type of gridlines. DEFAULT: 1
Labels passed to axis
. "FALSE" to suppress labeling. DEFAULT: NULL (internally, logVals$labs
Place all intermediate ticklines at the axis (without labeling). DEFAULT: FALSE
List of arguments passed to axis for allticks=TRUE. DEFAULT: NULL
Expression drawing over the ablines, like (points(x,y). Can be code within curly braces.
LabelAxisStyle for the orientation of the labels. DEFAULT: 1
Lower exponent OR vector with data, as in logVals
. DEFAULT based on par("usr")
High end exponent. DEFAULT: internally based on par("usr")
Override from and to as range.
Bases to be used in logVals
. DEFAULT: NA -> c(1,2,5) or 1, depending on from and to.
Symbol separating thousands, eg. space, comma, dot, etc. see "format" and "prettyNum". DEFAULT: "'"
Character separating comma values, see "format" and "prettyNum". DEFAULT: "."
See format
. DEFAULT: FALSE
Starting at which exponent should logVals
return an expression with exponents? DEFAULT: 5
Should "n * " be appended before 10^exp if n=1? DEFAULT: FALSE
base for $all
(for horizontal lines). DEFAULT: 1:9
Draw box at the end to overplot ablines
crossing the box? DEFAULT: TRUE
Further arguments passed to axis, like lwd, col.ticks, hadj, lty
, ...
Berry Boessenkool, berry-b@gmx.de, Sept 2014
logVals
, log10
x <- 10^runif(200, -1, 2)
plot(x, yaxt="n", log="y", pch=16)
logAxis(2)
# overplot vertical lines:
logAxis(2, expr=points(x, pch=16), base=1, col.axis=4, font=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))
# or just use the new logHist function (Feb 2016):
logHist(x, breaks=20, col=3)
# automatic calculation of from, to and base:
plot(1:3, axes=FALSE)
logAxis(1:2) # side can be a vector - nice, huh?
plot(-1:4, axes=FALSE)
logAxis(1:2) # treshold for base 1 instead of c(1,2,5) at 4 exponents exceeded.
plot(1:3, axes=FALSE)
logAxis(1:2, allticks=TRUE, lcol=NA)
par(mar=c(3,3,1,4))
plot(8:15) ; logAxis(4) # with exponents if they are above 5
plot(10^(1:4), ylim=10^c(4,1), type="o", log="y") # reverse axis:
plot(10^(1:5), log="y"); logAxis(4, exponent=3) # different treshold
plot(10^(1:5), log="y"); logAxis(4, expon=3, base=c(1,2,5), expobase1=TRUE)
plot(-8:5); logAxis(4, allbase=c(1,2,5)) # In case you want to mislead...
Run the code above in your browser using DataLab