简体   繁体   中英

seperate titles of multiples plots in R

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?

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)

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM