Due to data privacy, I use the mtcar dataset in ggplot2 to explain my question.
There are four graphs:
g1 <- ggplot(mtcars,aes(mpg,wt)) + geom_point() g2 <- ggplot(mtcars,aes(mpg,disp)) + geom_point() g3 <- ggplot(mtcars,aes(mpg,drat)) + geom_point() g4 <- ggplot(mtcars,aes(mpg,qsec)) + geom_point()
I want to put these four graphs in one graph, so I use the grid.arrange() function in the grid.Extra package:
grid.arrange(g1,g2,g3,g4,ncol=2)

And now, I want to add a title under each plot on this graph, something like the picture below (I modified it in Word, so itβs not beautiful)
Before the request, I searched in SO , and I know how to add a title below one graph, for example, use grid.text() or these three methods. Display text under the plot generated by ggplot2 or element_text(vjust=-10) , but I canβt apply it to four charts in one chart. Meanwhile, I have some results in the base plot. How to add a title for each plot in R? or The general main title is the shape bar compiled with the par (mfrow) parameter , qustion is what I want to hold it in ggplot2 , and the title below each chart, how to implement it? Thanks!
source share