R: How to use mtext to get a vertical label with aligned top with las = 1

I am trying to get a label on my vertical axis using mtextwhich is read horizontally ( las=1) and is located at the top of the axis.

My attempt to use las=1, adj=1. I can get the desired placement when I do not specify las=1, but as soon as I add an argument las=1, the placement adj=1will disappear. Here is the picture with the code. The left graph shows the correct placement, but without las=1. The right graph shows both arguments.

par(mfrow=c(1,2), mar=c(2,3,2,1))

plot(1, 1, ann=F)
mtext(col="blue", "y", side=2, line=2, adj=1)
mtext(side=3, "col=blue, side=2, adj=1")

plot(1, 1, ann=F)
mtext(col="red", "y", side=2, line=2, adj=1, las=1)
mtext(side=3, "col=red, side=2, adj=1, las=1")

enter image description here

I tried fussing with padj, but that only moves the shortcut up and down a bit. Also, I know that an argument atcan, but it seems too tame.

+4
1

text(). x y, , , .. , ( )

par(mar=c(2,3,2,1))
plot(1, 1, ann=F)
mtext(side=3, "convertX/Y")
xx<-grconvertX(grconvertX(0, "nfc","inches") , "inches","user")
yy<-grconvertY(par("din")[2]-par("cin")[2]*5/2, "inches","user")
text(xx,yy,"y", col="green", cex=1.5, xpd=NA, pos=4)

x , y , . "y" , .

enter image description here

0

Source: https://habr.com/ru/post/1545313/


All Articles