0

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

swchen
  • 643
  • 2
  • 8
  • 24

1 Answers1

1

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

jalapic
  • 13,792
  • 8
  • 57
  • 87