R绘图窗口分屏 - 二阶

时间:2014-01-04 05:53:52

标签: r plot

我想做点什么

par(mfrow=c(2,1));

然后画出

ts.plot(rnorm(15));

然后我想将第2行进一步拆分为2-cross-3矩阵,再次对par()进行理论子调用...

2 个答案:

答案 0 :(得分:3)

在这里查看布局,标准等的一个很好的解释:http://www.stat.tamu.edu/~jkim/Rfigurelayout.pdf

您的布局

m <- matrix(c(1,1,1,
              2,3,4,
              5,6,7), ncol=3, by=T)
l <- layout(m)
layout.show(l)  # show layout to doublecheck

# layout cells are filled in the order of the numbers
# set par, e.g. mar each time if required

for (i in 1:7) {
  par(mar=c(i,i,i,i))
  hist(rnorm(100), col=i)
}

enter image description here

答案 1 :(得分:1)

set.seed(1618)
multiplot(height = 8, width = 6, rows = 5, cols = 3, matrix = c(1,1,1, 1,1,1, 2,3,4,5,6,7,8,9,10))
for (i in 11:20) {
  plot(rcauchy(i), pch = 19, col = i)
}
dev.copy2pdf(file = "./tmp.pdf")

enter image description here

multiplot <- function(width = 8.5, height = 11, rows, cols, matrix = c(1, 1)) {
    x11(width, height)
    layout(matrix(c(matrix), rows, cols, byrow = TRUE))
}
相关问题