I know how to print my own labels along the x axis:
plot(1:10,xlab = "My label", axes = FALSE)
axis(1,at=seq(1,10,by=2),labels=c("first","second","third","fourth","fifth"))
Is there a way to make the labels print vertically along the axis rather than
horizontally? (I'm not sure if this is even going to look all right, but I
want to check it out if it is possible.)
Anna
plot vertical labels along x axis
5 messages · Anna H. Pryor, Uwe Ligges, Marc Schwartz +1 more
Anna H. Pryor wrote:
I know how to print my own labels along the x axis:
plot(1:10,xlab = "My label", axes = FALSE)
axis(1,at=seq(1,10,by=2),labels=c("first","second","third","fourth","fifth"))
Is there a way to make the labels print vertically along the axis rather than
horizontally? (I'm not sure if this is even going to look all right, but I
want to check it out if it is possible.)
Anna
See ?par, in particular its argument "las". Uwe Ligges
-----Original Message-----
From: r-help-bounces at stat.math.ethz.ch
[mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Anna H. Pryor
Sent: Wednesday, May 07, 2003 10:25 AM
To: R-help mailing list
Subject: [R] plot vertical labels along x axis
I know how to print my own labels along the x axis:
plot(1:10,xlab = "My label", axes = FALSE)
axis(1,at=seq(1,10,by=2),labels=c("first","second","third","fou
rth","fifth"))
Is there a way to make the labels print vertically along the
axis rather than
horizontally? (I'm not sure if this is even going to look all
right, but I
want to check it out if it is possible.)
Anna
Try this sequence:
plot(1:10,xlab = "My label", axes = FALSE)
axis(1, at=seq(1,10,by=2),
labels=c("first","second","third","fourth","fifth"), las = 2)
See ?par for more information on the use of the 'las = 2' argument,
which sets the labels to be printed perpendicular to the axis.
Hope that helps,
Marc Schwartz
If you want an angle other than vertical, the problem is harder. The
argument "srt" works with "axis" in S-Plus 6.1 but not in R.
Consider the following:
plot(1:2)
text(1:2, rep(2, 2), c("adsf", "qwer"), srt=45)
If all you want is vertical, then you don't want this. However, this
provides another range of options.
Spencer Graves
Marc Schwartz wrote:
-----Original Message-----
From: r-help-bounces at stat.math.ethz.ch
[mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Anna H. Pryor
Sent: Wednesday, May 07, 2003 10:25 AM
To: R-help mailing list
Subject: [R] plot vertical labels along x axis
I know how to print my own labels along the x axis:
plot(1:10,xlab = "My label", axes = FALSE)
axis(1,at=seq(1,10,by=2),labels=c("first","second","third","fou
rth","fifth"))
Is there a way to make the labels print vertically along the
axis rather than
horizontally? (I'm not sure if this is even going to look all
right, but I
want to check it out if it is possible.)
Anna
Try this sequence:
plot(1:10,xlab = "My label", axes = FALSE)
axis(1, at=seq(1,10,by=2),
labels=c("first","second","third","fourth","fifth"), las = 2)
See ?par for more information on the use of the 'las = 2' argument,
which sets the labels to be printed perpendicular to the axis.
Hope that helps,
Marc Schwartz
______________________________________________ R-help at stat.math.ethz.ch mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
-----Original Message----- From: r-help-bounces at stat.math.ethz.ch [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Spencer Graves Sent: Wednesday, May 07, 2003 11:45 AM To: mschwartz at medanalytics.com Cc: 'R-help mailing list' Subject: Re: [R] plot vertical labels along x axis If you want an angle other than vertical, the problem is harder. The
argument "srt" works with "axis" in S-Plus 6.1 but not in R.
Consider the following:
plot(1:2)
text(1:2, rep(2, 2), c("adsf", "qwer"), srt=45)
If all you want is vertical, then you don't want this. However, this
provides another range of options. Spencer Graves
SNIPPED
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