draw the y-label on the top of y axis

755 views Asked by At

I want draw the ylab on the top of the y axis, which code can I use?

Here is the example

par(mar=c(4,6,4,4))
plot(rnorm(100), ylab="")
mtext(side=2, text="Label", las=1, line=2)

I want draw the ylabel at the top of y axis which red arrow indicated.

image

1

There are 1 answers

0
jalapic On BEST ANSWER

You could do it like this, by finding the top left corner and fixing it to it.

par(mar=c(4,6,4,4))
plot(rnorm(100), ylab="")

loc <- par("usr")
text(loc[1], loc[4], "Label", pos = 2, xpd = T)

Playing around with pos and adding adj could change the position a bit.

enter image description here