0

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?

Roman
  • 17,008
  • 3
  • 36
  • 49
carol
  • 153
  • 1
  • 4
  • 17
  • 1
    I would really recommend to use a different plot package that supports some kind of multi-facet plot, e.g. `lattice` or `ggplot2`. My suggestion is `ggplot2`. – Paul Hiemstra Feb 15 '16 at 14:42

1 Answers1

1

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

Roman
  • 17,008
  • 3
  • 36
  • 49