Plotting 5 graphs in a 3-2 layout in R

-----   -----   -----
| A |   | B |   | C |
-----   -----   ----
    -----   -----
    | D |   | E |
    -----   -----

      

or

    -----   -----  
    | A |   | B |   
    -----   -----  
-----   -----   -----
| C |   | D |   | E |
-----   -----   -----

      

I have 5 plots and I wanted to fit into 1 plot, structured as above. Got some kick from this post: Plotting 3 graphs in a 2-1 layout in R to use the layout () function, but just failed to get it right.

Can anyone please help? Thank you so much.

Update


Just tied my plot, after committing the structure. Many thanks for the help. my plot

+3


source to share


2 answers


You can do this with layout

. Just make a 6 * 2 grid and make sure each area is 2 cells wide. Insert a two-line string with some zeros to align them well.

layout(mat = matrix(c(1,1,2,2,3,3,
                      0,4,4,5,5,0), nrow = 2, byrow = TRUE))
layout.show(n = 5)

      



enter image description here

+8


source


you can get the aforementioned graph using layout since you think you cannot divide the width of the second row with odd columns.

layout(matrix(c(1,2,3,4,4,5), 2, 3, byrow = TRUE))
hist(as.matrix(1:10))
hist(as.matrix(1:10))
hist(as.matrix(1:10))
hist(as.matrix(1:10))
hist(as.matrix(1:10))

      



enter image description here

+1


source







All Articles