Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

changing title in multiplot ggplot2 using grid.arrange

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.

like image 431
moadeep Avatar asked Feb 06 '13 09:02

moadeep


People also ask

Can I add title in grid arrange?

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.

How do I arrange multiple Ggplots?

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.

How do you change to size of grid arrange in R?

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.

What package is grid arrange in R?

grid. arrange() function sets up a gtable layout to place multiple grobs on a page. It is located in package "gridExtra".


2 Answers

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).

like image 185
George Dontas Avatar answered Oct 26 '22 20:10

George Dontas


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))) 
like image 26
MBorg Avatar answered Oct 26 '22 19:10

MBorg