Reputation: 2214
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?
Thanks!
Upvotes: 2
Views: 3760
Reputation: 2115
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")
You will need to make sure the graphics device is large enough to receive large numbers of plots.
Upvotes: 1