xlimlabel: Calulate horizontal limit in user coordinates for adding...

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

View source: R/xlimlabel.R

Description

Calculates the x-axis limits when adding (long) labels to a plot

Usage

1
xlimlabel(x, xlabels, pos = 4, offset = 0.5, ...)

Arguments

x

numeric vector of horizontal coordinates

xlabels

character vector, specifying text to be written

pos

position specifier for text; values of 1, 2, 3, and 4, respectively, indicate positions below, to the left of, above, and to the right of the coordinates

offset

offset of the label from the coordinate in fractions of a character width

...

Additional par arguments

Details

See text for details on pos and offset.

Value

Minimum and maximum x-axis limits for adding horizontal text

Author(s)

Aimee Teo Broman

See Also

text

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
x <- runif(15, -1, 1)*10
xlabs <- sapply(sample(1:20, 15, replace=TRUE),
                function(a) paste(LETTERS[1:a], collapse=""))
par(mfrow=c(2,1), las=1)
## Labels to the left ##
xlims <- xlimlabel(x, xlabs, pos=2)
plot(x, 1:length(x), xlim=xlims, ylab="Index")
text(x, 1:length(x), xlabs, pos=2)
## Labels to the right ##
xlims <- xlimlabel(x, xlabs, pos=4, cex=0.7)
plot(x, 1:length(x), xlim=xlims, ylab="Index")
text(x, 1:length(x), xlabs, pos=4, cex=0.7)

kbroman/broman documentation built on Sept. 24, 2018, 1:16 a.m.