Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gridExtra 2.0.0 change title size

Tags:

plot

r

gridextra

I know that gridExtra has been updated. As a result, I'm left wondering how to change title sizes. This no longer works

   grid.arrange(a, b, c, d,ncol=2, 
      nrow=2, main=textGrob("Title", gp=gpar(fontsize=15,font=8)))

That no longer works, the option for main has been changed to top but I can't figure out the textGrob features to alter the font size). Any clues? Thanks

like image 261
Cyrus Mohammadian Avatar asked Aug 28 '15 22:08

Cyrus Mohammadian


2 Answers

First, import the package grid with either library() or require(). Second, change main to top in your code.

See below:

library(grid)

 grid.arrange(a, b, c, d,ncol=2, 
     nrow=2, top=textGrob("Title", gp=gpar(fontsize=15,font=8)))

I ran into a similar issue with gridExtra v2.0.0, receiving the following error:

Error in arrangeGrob(...) : could not find function "textGrob"

indicating that grid wasn't loaded as a dependency for gridExtra. I resolved it by requiring or importing the library grid by either:require(grid) or library(grid).

Hope that helps.

like image 146
rolyat Avatar answered Sep 21 '22 09:09

rolyat


Short answer: the title is now set with top = textGrob("Title")

Short explanation: the original argument names were all over the place ("main", "sub", "legend"(!), "left"), so this update brought more consistency (top/bottom/right/left).

like image 24
baptiste Avatar answered Sep 19 '22 09:09

baptiste