rlayout

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.

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