On Fri, 2006-06-09 at 14:13 +0100, d d sutcliffe at durham ac uk
wrote:> Hi,
>
> I have been working through one of the examples on the FAQ about
> rotating the labels on the x axis, I need to do the same but for the y
> axis. I have managed to change some of the code, but I am still not
> getting there, there is still something wrong. My syntax is as follows:
>
>
> > par(mar = c(5, 7, 4, 2) + 0.1)
> > plot(1 : 8, yaxt = "n", ylab = "")
> > axis(2, labels = FALSE)
> > labels <- paste("Label", 1:8, sep = " ")
> > text(1:8, par("usr")[3] - 0.25, srt = 45, adj = 1,
> + labels = labels, xpd = TRUE)
>
> If anybody knows what is wrong then I would appreciate your help...been
> working on this for far too long already!
>
> Regards,
>
> Dan
Dan,
You need to adjust two things:
1. par("usr")[3] is the minimum value of the y axis. You would use
this
(as in the FAQ example) when you want to move the text vertically below
the x axis. See ?par for more information.
In your case, you want to move the text to the left of the y axis. Thus
you need to use par("usr")[1] instead, which is the minimum value of
the
x axis.
2. In the text call, you are setting the 'x' coordinate to 1:8, which is
why the labels are appearing along the x axis, rather than along the y
axis. So you want to set the y coordinate to 1:8 instead.
So, the adjusted sequence would be:
par(mar = c(5, 7, 4, 2) + 0.1)
plot(1 : 8, yaxt = "n", ylab = "")
axis(2, labels = FALSE)
labels <- paste("Label", 1:8, sep = " ")
text(par("usr")[1] - 0.25, 1:8, srt = 45, adj = 1,
labels = labels, xpd = TRUE)
HTH,
Marc Schwartz