Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Using R layout to resize and center first row

I am trying to create a plot in R with three panels using the layout function.

If I use e.g.

layout = layout(matrix(c(1,1,2,3),2,2,byrow=TRUE)
layout = plot(x1,y1,main="Fig 1A")
layout = plot(x2,y2,main="Fig 1B")
layout = plot(x3,y3,main="Fig 1C")

then I get a wide, stretched out plot for x1,y1 and the desired square plot for x2,y2, and x3,y3.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

What I would like to create is a three panel plot where the x1,y1 plot is a square of the same proportions as those in the second row, and centered above the B,C plots (i.e. Fig 1A, 1B, 1C are of the same size/proportions, with 1A centered above B and C). The height and width arguments of the layout function will let me rescale the relative sizes of the two panels in the second row, but I don’t see how this can be used to achieve the desired position and proportions for 1A.

Is there a way to do this using layout in R?

>Solution :

Use 0 for space you don’t want to be part of a plot:

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

enter image description here

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading