R: การตั้งค่าความสูงของพล็อตหลายรายการด้วยพาร์

ฉันกำลังพยายามพล็อตแผนภูมิสามแผนภูมิด้วยกัน โดยแผนภูมิหนึ่งอยู่ใต้แผนภูมิอื่น ฉันต้องการทำให้ความสูงของแผนภูมิแรกใหญ่เป็นสองเท่าของแผนภูมิอื่นๆ โดยใช้พาร์ แต่ฉันประสบปัญหากับพารามิเตอร์ความสูง

par(mfrow = c(3, 1),mar=c(2, 4, 2, 0.2), heights=c(2,1,1))

plot(x=1:100,y=cumsum(sample(c(-1, 1), 100, TRUE)), type="l")
plot(x=1:100,y=cumsum(sample(c(-1, 1), 100, TRUE)), type="l")
plot(x=1:100,y=cumsum(sample(c(-1, 1), 100, TRUE)), type="l")

ขอขอบคุณสำหรับความช่วยเหลือของคุณ.


person adam.888    schedule 10.05.2015    source แหล่งที่มา


คำตอบ (1)


คุณสามารถใช้ layout สำหรับสิ่งนี้:

#the first argument is a matrix that shows the order of the graphs
#in this case the matrix has 1 column and 3 rows. therefore, graphs 1,2,3
#will be ploted in this order, one below the other
#you then need to adjust the heights and the widths for each plot
nf <- layout(matrix(c(1,2,3),ncol=1), widths=c(4,4,4), heights=c(2,1,1), TRUE) 
#typing the below command will let you see how the plots will be filled in.
#layout.show(nf)

#then you just run your plots
plot(x=1:100,y=cumsum(sample(c(-1, 1), 100, TRUE)), type="l")
plot(x=1:100,y=cumsum(sample(c(-1, 1), 100, TRUE)), type="l")
plot(x=1:100,y=cumsum(sample(c(-1, 1), 100, TRUE)), type="l")

ป้อนคำอธิบายรูปภาพที่นี่

person LyzandeR    schedule 10.05.2015