How to use layout() function in R?

后端 未结 1 401
一整个雨季
一整个雨季 2021-01-02 01:00

I just took an example which produces four plots combined with the layout function. However, I cannot figure out how the matrix inside layout() con

相关标签:
1条回答
  • 2021-01-02 01:42

    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).

    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.

    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)
    

    0 讨论(0)
提交回复
热议问题