多个图表相同的图

时间:2013-02-25 04:09:42

标签: r

如何在2个不同的行中维护不同的图表数量。例如,我想要第1行中的1个图表和第2行中的10个图表。我该怎么做?

我最接近的是:

> par(mfrow=c(2,1))
> x=c(1,2,3324,324)
> y=c(1,2,32,2323)
> plot(x,y)
> plot(x,y)

这会在另一个图表上创建1个图表,但我无法获得第2行以便能够处理10个图表

1 个答案:

答案 0 :(得分:3)

使用layout,一旦创建了正确的矩阵

,就很容易了
     [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
[1,]    1    1    1    1    1    1    1    1    1     1
[2,]    2    3    4    5    6    7    8    9   10    11


layout(matrix(c(rep(1,10),2:11),nrow=2,byrow=T))
 x=c(1,2,3324,324)
 y=c(1,2,32,2323)
 plot(x,y)
 replicate(n=10,plot(x,y))

enter image description here

编辑给出不同的宽度

mat <- matrix(c(rep(1,10),2:11),nrow=2,byrow=T)
layout(mat, widths = c(rep(1,5),rep(2,3),rep(3,2)))

我喜欢layout.show功能。控制你的布局非常方便。

layout.show(n = 11)

enter image description here