Skip to content
Prev 31723 / 398506 Next

plot vertical labels along x axis

Actually, there is a trick for using text() with 'srt' to achieve 45
degree rotated x-axis labels.  This involves using par("xpd") and
par("usr"). 

To wit, using Anna's initial example:

plot(1:10, xlab = "My label", axes = FALSE)
axis(1, at=seq(1, 10, by=2), labels = FALSE)
text(seq(1, 10, by=2), par("usr")[3] - 0.2, labels = c("first",
"second", "third", "fourth", "fifth"), srt = 45, pos = 1, xpd = TRUE)

By adjusting the negative offset of 'par("usr")[3] - 0.2', you can
move the labels vertically to account for the length of the text
components. A larger value moves the text down further below
par("usr")[3], which is the value of y at the intersection of the
x-axis.

HTH,

Marc Schwartz