如何在R中使用layout()函数? [英] How to use layout() function in R?
问题描述
我只是举了一个例子,该例子生成了四个与layout
函数结合的图.但是,我无法弄清楚layout()
内的矩阵如何连接到这些图的布局.
I just took an example which produces four plots combined with the layout
function. However, I cannot figure out how the matrix inside layout()
connects to the layout of these plots.
layout(matrix(c(1, 1, 1,
2, 3, 4,
2, 3, 4), nr=3, byrow=T))
hist(rnorm(25), col="VioletRed")
hist(rnorm(25), col="VioletRed")
hist(rnorm(25), col="VioletRed")
hist(rnorm(25), col="VioletRed")
推荐答案
在您的示例中,图形设备被划分为3 x 3单元格,列/行的宽度/高度相等(因为这是默认设置)不提供widths
和heights
参数时的行为).
For your example, the graphics device is split into a 3 x 3-cell grid, with columns/rows having equal width/height (since that is the default behaviour when you don't provide widths
and heights
arguments).
在调用layout
之后,第一个后续绘图将填充矩阵的值为1的单元格(即前三个单元格).第二个图将填充矩阵值为2的单元格(左下和中左单元格),依此类推.
After calling layout
, the first subsequent plot will fill the cells for which the matrix has value 1 (i.e., the top three cells). The second plot will fill the cells for which the matrix has value 2 (bottom-left and middle-left cells), and so on.
要获取随后布局的预览,可以使用layout.show
:
To get a preview of the ensuing layout, you can use layout.show
:
layout(matrix(c(1, 1, 1,
2, 3, 4,
2, 3, 4), nrow=3, byrow=TRUE))
layout.show(n=4)
这篇关于如何在R中使用layout()函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!