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