我試圖擺脫在R與我的數據R使用繪圖功能在x軸的雙標籤。如何擺脫x軸上的雙標籤(R中的繪圖函數)
的樣本數據可以這樣創建:
Data=read.table(textConnection("
Geslacht y x1 x2 x3 x4 x5 x6 x7 x8 x9
M 0.00 5 6 16 9 5 13 14 5 7
M 0.25 6 7 17 9 5 13 17 5 7
M 0.67 12 12 28 14 7 21 24 13 13
"),head=TRUE)
我到目前爲止已經使用了下面的代碼:
Data <- read.table(Data, header=TRUE, sep="\t", na.string="NA", strip.white=TRUE)
par(new=T)
plot(Data$y, Data$x1, xlab="Chronological Age", ylab="%DNA methylation", cex = 0.9, col="black", pch=20, xlim=c(0, 100), ylim=c(0, 100), font.lab=2)
par(new=T)
plot(Data$y, Data$x2, pch=20, axes=F, ylab="", cex= 0.9, col="blue", xlim=c(0, 100), ylim=c(0, 100))
par(new=T)
plot(Data$y, Data$x3, pch=20, axes=F, ylab="", cex= 0.9, col="red", xlim=c(0, 100), ylim=c(0, 100))
par(new=T)
plot(Data$y, Data$x4, pch=20, axes=F, ylab="", cex= 0.9, col="green", xlim=c(0, 100), ylim=c(0, 100))
par(new=T)
plot(Data$y, Data$x5, pch=20, axes=F, ylab="", cex= 0.9, col="coral4", xlim=c(0, 100), ylim=c(0, 100))
par(new=T)
plot(Data$y, Data$x6, pch=20, axes=F, ylab="", cex= 0.9, col="darkgrey", xlim=c(0, 100), ylim=c(0, 100))
par(new=T)
plot(Data$y, Data$x7, pch=20, axes=F, ylab="", cex= 0.9, col="darkorchid1", xlim=c(0, 100), ylim=c(0, 100))
par(new=T)
plot(Data$y, Data$x8, pch=20, axes=F, ylab="", cex= 0.9, col="darkgoldenrod1", xlim=c(0, 100), ylim=c(0, 100))
par(new=T)
plot(Data$y, Data$x9, pch=20, axes=F, ylab="", cex= 0.9, col="forestgreen", xlim=c(0, 100), ylim=c(0, 100))
legend("bottomright", title="CpG regions", cex=.8, c("CpG1 ELOVL2","CpG2 ELOVL2","CpG3 ELOVL2", "CpG4 ELOVL2", "CpG5 ELOVL2", "CpG6 ELOVL2", "CpG7 ELOVL2", "CpG8 ELOVL2", "CpG9 ELOVL2"),
pch=c(20,20,20,20,20,20,20,20,20),col=c("black","blue", "red", "green", "coral4", "darkgrey","darkorchid1","darkgoldenrod1","forestgreen",horiz=FALSE))
我可以將圖片不得發佈,由於是新手..
有誰知道爲什麼我會在x軸上得到雙重標籤?第二個標籤是「Data $ y」,即使我在代碼行3中指定了xlabel。
嘗試指定'xlab =「」'在'plot'呼叫的其餘部分。 – BenBarnes
看看函數'matplot'。這將節省很多線路。 –