I'm trying to arrange my plots as shown in the figure in R.

I can create a 2 by 2 plot matrix using:

par(mfrow=c(2,2)) 

Is it possible to further create subplots within the 4th square as shown in the figure?enter image description here

Thanks!

1

1 Answer

You can use the layout function to arrange graphics plots. layout takes a matrix that indicates the order in which to add plots to the graphics device.

m1 <- matrix(c( 1, 1, 2, 2, 1, 1, 2, 2, 3, 3, 4, 5, 3, 3, 6, 7), nrow = 4, ncol = 4, byrow = TRUE) m1 # [,1] [,2] [,3] [,4] # [1,] 1 1 2 2 # [2,] 1 1 2 2 # [3,] 3 3 4 5 # [4,] 3 3 6 7 layout(m1) hist(rnorm(100), col = "red") hist(rnorm(100), col = "orange") hist(rnorm(100), col = "yellow") hist(rnorm(100), col = "green") hist(rnorm(100), col = "lightblue") hist(rnorm(100), col = "blue") hist(rnorm(100), col = "violet") 

colourful histograms showing where graphics are added

You will need to make sure the graphics device is large enough to receive large numbers of plots.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.