1
我想知道如何使用下面的矩陣結構將BELOW 3 R圖合併到一個屏幕中?在一個屏幕中包含3個不同的R圖
注:我已經註解了代碼,但最好的方法是運行每個圖以查看它的外觀。
這裏是我的R代碼裏面:
m2 <- matrix(c(0,2,2,2,2, 1,2,2,2,2, 1,2,2,2,2, 0,2,2,2,2 ), nrow=5, ncol=4) # matrix m2
m3 <- matrix(c(0,2,2,2,2,0, 1,2,2,2,2,3, 1,2,2,2,2,3, 0,2,2,2,2,0), nrow=6, ncol=4) # matrix m3
TL <- T ## NOW TRUE
if(TL==T) {layout(m3)}else{layout(m2)} ## IF TL==T, split the screen according to *m3*
## Plot # 1: ###############################################
curve(dcauchy(x,0,1),-6,6,yaxt="n",bty="n",xaxs="i",xlab="GG",font.lab=2,lwd=2,col="cyan2",ylab = "")
## Plot #2: ###############################################
plot(1, 1, type = "n", xlim = c(0,1.5), ylim = c(.01, 3),log="y", bty="n", axes=F, xaxs="i",
xlab = "GGG", ylab=expression(paste(bold('BBB'))),font.lab=2,cex.lab=2)
axis(side=1, at = seq(0,1.5,.25),labels = c("0",".25",".5",".75","1","1.25","1.5"))
axis(side=2, at = c(.01, 1/30, 1/10, 1/3, 1, 3),labels = c("1/100", "1/30", "1/10", "1/3", "1", "3"),las=1)
axis(side=4,at = c(.01, 1/30, 1/10, 1/3, 1,3),labels = F)
axis(side=4,at = c(.01*1.8, (1/30)*1.7, (1/10)*1.8, (1/3)*1.7, 1*1.7), c("YES", "NO", "YES", "NO", "NO"),tick=F,las=1,font=2,
mgp=c(1.5,.3, 0),cex.axis=1.8)
## Plot #3: ###############################################
ci <- c(0.09253967, 0.48434172)
plot(1, 1, ty="n" ,ann=F, yaxt="n", bty="n", xlim=c(ci[1], ci[2]), ylim=c(0, 1), xaxt="n")
axis(side = 1, at = ci)
arrows(ci[1], .01, ci[2], .01, code=3, lwd=2, angle = 90, length = .08)
mtext(side=1,"GGG",line=2.8, font=2, cex= 1.5)
非常感謝!有什麼方法可以在'layout()'流體中創建'width ='和'height ='參數嗎?我的意思是如果劇情以任何方式改變,這兩個參數會自動調整自己? – rnorouzian
寬度和高度的默認值是一系列1重複正確數量的行和列,所以您需要更具體地說明您希望的是什麼樣的「流動性」。 –
我使用'png'的唯一原因是創建一個可以看到的圖像。您應該能夠設置您的操作系統特定的交互式屏幕設備,以具有足夠的尺寸來容納這些圖。 –