seperate titles of multiples plots in R

544 views Asked by At

I plot 5 boxplots (boxplot) in two rows with par(mfrow = c(2,5), oma = c(0,0,2,2)).

par(mfrow = c(2,5),oma = c(0, 2, 2, 0))
boxplot(x,...)
title (main = "title1", outer = T)
boxplot(y,...)
title (main = "title2", outer = T)#overwrites title 1

how to place the title2 above the 2nd row of boxplots?

1

There are 1 answers

0
Roman On

You can use mtext to plot the title wherever you want.

data("mtcars")
par(mfrow = c(2,5),oma = c(0, 2, 2, 0))
replicate(10,boxplot( mpg~cyl,mtcars))
mtext("title1",line = 0,outer=T,font = 2)
mtext("title2",line = -24,outer=T,font = 2)

enter image description here