I have a compilation of 4 plots drawn together with par(mfrow=c(2,2))
. I would like to draw a common title for the 2 above plots and a common title for the 2
You can use the function layout()
and set two plotting regions which occurs in both columns (see the repeating numbers 1 and 3 in the matrix()
). Then I used plot.new()
and text()
to set titles. You can play with margins and heights to get better representation.
x<-1:10
par(mar=c(2.5,2.5,1,1))
layout(matrix(c(1,2,3,4,1,5,3,6),ncol=2),heights=c(1,3,1,3))
plot.new()
text(0.5,0.5,"First title",cex=2,font=2)
plot(x)
plot.new()
text(0.5,0.5,"Second title",cex=2,font=2)
hist(x)
boxplot(x)
barplot(x)