I have managed to make a 2x2 plot using grid.arrange:
library(gridExtra) grid.arrange(p1,p3,p2,p4, ncol=2, nrow=2, top = "Daily QC: Blue")
The main title of this multiplot is very small. Is there a way to change the title text size and font.
Titles and subtitlesAdding a global title and/or subtitle to a page with multiple plots is easy with grid. arrange() : use the top , bottom , left , or right parameters to pass either a text string, or a grob for finer control.
To arrange multiple ggplot2 graphs on the same page, the standard R functions - par() and layout() - cannot be used. The basic solution is to use the gridExtra R package, which comes with the following functions: grid. arrange() and arrangeGrob() to arrange multiple ggplots on one page.
To change the size of plots arranged using grid. arrange, we can use heights argument. The heights argument will have a vector equal to the number of plots that we want to arrange inside grid.
grid. arrange() function sets up a gtable layout to place multiple grobs on a page. It is located in package "gridExtra".
main=textGrob("Daily QC: Blue",gp=gpar(fontsize=20,font=3))
Edit with v>=2.0.0 of gridExtra, main
has become top
(for consistency with bottom
, left
and right
).
Due to changes in both packages grid
and gridExtra
, the current answer is outdated. Library package grid
is also required to use textGrob
and gpar
.
The new code should include both packages:
library(grid) library(gridExtra) grid.arrange(p1,p3,p2,p4, ncol=2, nrow=2, top = textGrob("Daily QC: Blue",gp=gpar(fontsize=20,font=3)))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With