我知道你们中的一些人会很快捷.我只想使用水平y轴标签mtext().它与我猜想有关,但我一直在浪费最后2个小时试图找出它......在下面的例子中,我只想让y标签(myLab)水平并左对齐.
myLab <- c("aaaaaaa", "bb", "c")
par(oma=c(0,10,0,0)) # make a large left maring for the labels
plot(x=c(1:3),
     y=c(1:3),
     pch="|",
     lwd=3,
     tck=0.01,
     yaxt="n",
     ylab="",
     xlab="my legend",
     at= c(1:3),
     )
mtext(text=myLab,
      side=2,
      outer = FALSE,
      at=c(1:3)
      )
我不需要使用mtext().如果您有更好的选择,请告诉我.
谢谢!
使用las参数:
mtext(text=myLab, las=1,
       side=2,
       outer = FALSE,
       at=c(1:3)
       )
将它们带到边缘,但您可以在myLab值中填充尾随空格.您可以使用adj值0(相对于默认值1)左对齐:
 plot(x=c(1:3),
      y=c(1:3),
      pch="|",
      lwd=3,
      tck=0.01,
      yaxt="n",
      ylab="",
      xlab="my legend"  # removing extraneous `at` value that only throws a warning
      )
 mtext(text=myLab, las=1, adj=0,
        side=2,
        outer = FALSE,
        line=3.5, at=1:3
        )