简体   繁体   English

如何在基本 plot R 中旋转 ylab

[英]How to rotate ylab in basic plot R

I've created three plots, I want to set the ylab text on the top and rotate text in ylab = "text" , but I can't do it using text, or par("usr") and draw a new axis.我已经创建了三个图,我想将 ylab 文本设置在顶部并在ylab = "text"中旋转文本,但我不能使用文本或par("usr")并绘制一个新轴。 How to do it?怎么做?

steps1 <- c(77:82)
steps2 <- c(72:82)
steps3 <- c(62:82)
opar <- par(no.readonly=TRUE)
par(mfrow=c(1,3))
par(las = 1)
plot(steps1, dfL1_F[77:82],
type= "o",pch=16, lty=1, col="black", xlab = 'Step finals', ylab = 'Max F, A.U.')
abline(h=c(0.000450), lwd=1.5, lty=2, col="red")
grid(nx = NULL, ny = NULL,lty = 2, col = "gray", lwd = 1)
plot(steps2, dfL1_F[72:82],
type= "o",pch=16, lty=1, col="black", xlab = 'Step finals', ylab = 'Max F, A.U.')
grid(nx = NULL, ny = NULL,lty = 2, col = "gray", lwd = 1)
abline(h=c(0.000450), lwd=1.5, lty=2, col="red") 
plot(steps3, dfL1_F[62:82],
type= "o",pch=16, lty=1, col="black", xlab = 'Step finals', ylab = 'Max F, A.U.')
grid(nx = NULL, ny = NULL,lty = 2, col = "gray", lwd = 1)
abline(h=c(0.000450), lwd=1.5, lty=2, col="red")   
par(opar)

Sorry, for trouble, this is input data:对不起,麻烦了,这是输入数据:

c(0.090803, 0.053571, 0.059279, 0.081256, 0.898884, 0.046667, 0.036066, 
0.024925, 0.109469, 0.030897, 0.052733, 0.013766, 0.012801, 
0.012609, 0.009315, 0.015449, 0.031633, 0.009842, 0.014112, 0.016614, 
0.006702, 0.006865, 0.007912, 0.023806, 0.023373, 0.009024, 0.008952, 
0.042152, 0.010782, 0.006892, 0.006798, 0.006797, 0.006586, 0.020231, 
0.040914, 0.007164, 0.008807, 0.004308, 0.009495, 0.008776, 0.006001, 
0.004247, 0.052963, 0.006756, 0.02555, 0.002508, 0.003779, 0.00453, 
0.003253, 0.006861, 0.009106, 0.001776, 0.004892, 0.005216, 0.010059, 
0.0045, 0.003041, 0.005896, 0.00287, 0.003333, 0.008464, 0.003295, 
0.002963, 0.001889, 0.0021, 0.001508, 0.002127, 0.001287, 0.001515, 
0.001391, 0.002729, 0.002551, 0.001971, 0.001635, 0.000612, 0.00097, 
0.000504, 3e-04, 0.000385, 0.000322, 0.000111, 0.000111)

You can remove the ylab and create an adjustable ylab using mtext Using mtext you can move the title left and right using adj , move the title up and down using padj , and change the size of the font using cex .您可以删除ylab并使用mtext创建可调整的ylab使用mtext您可以使用adj左右移动标题,使用padj上下移动标题,并使用cex更改字体大小。 You may have to play with padj and adj a bit to get the label in the right position for your needs您可能需要稍微玩一下padjadj才能在正确的 position 中获得 label 以满足您的需求

steps1 <- c(77:82)
steps2 <- c(72:82)
steps3 <- c(62:82)
opar <- par(no.readonly=TRUE)
par(mfrow=c(1,3))
par(las = 1)
plot(steps1, dfL1_F[77:82],
     type= "o",pch=16, lty=1, col="black", xlab = 'Step finals', ylab = '')
abline(h=c(0.000450), lwd=1.5, lty=2, col="red")
#adj will move the title left and right and padj moves the title up and down
mtext("MAX F", col = "black", adj=-0.4, padj=-1, cex=0.6)
grid(nx = NULL, ny = NULL,lty = 2, col = "gray", lwd = 1)
plot(steps2, dfL1_F[72:82],
     type= "o",pch=16, lty=1, col="black", xlab = 'Step finals', ylab = '')
#adj will move the title left and right and padj moves the title up and down
mtext("MAX F.", col = "black", adj=-0.4, padj=-1, cex=0.6)
grid(nx = NULL, ny = NULL,lty = 2, col = "gray", lwd = 1)
abline(h=c(0.000450), lwd=1.5, lty=2, col="red") 
plot(steps3, dfL1_F[62:82],
     type= "o",pch=16, lty=1, col="black", xlab = 'Step finals', ylab = '')
#adj will move the title left and right and padj moves the title up and down
mtext("MAX F", col = "black", adj=-0.4, padj=-1, cex=0.6)
grid(nx = NULL, ny = NULL,lty = 2, col = "gray", lwd = 1)
abline(h=c(0.000450), lwd=1.5, lty=2, col="red")   
par(opar)

示例1

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM