[英]How to rotate ylab in basic plot R
我已經創建了三個圖,我想將 ylab 文本設置在頂部並在ylab = "text"
中旋轉文本,但我不能使用文本或par("usr")
並繪制一個新軸。 怎么做?
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)
對不起,麻煩了,這是輸入數據:
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)
您可以刪除ylab
並使用mtext
創建可調整的ylab
使用mtext
您可以使用adj
左右移動標題,使用padj
上下移動標題,並使用cex
更改字體大小。 您可能需要稍微玩一下padj
和adj
才能在正確的 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)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.