Questions tagged [gridextra]

`gridExtra` is a package providing convenience functions and extensions on top of `grid`, a low-level framework for R graphics. This facilitates the arrangement of multiple ggplot objects on a single plot.

Description

gridExtra is an R package based on grid graphics, providing a few high-level functions to draw custom graphical objects and organise them on a page.

Additional Resources

  1. Official CRAN documentation.
  2. Info provided by RDocumentation can be found here.
  3. The official guide, written by the package's creator, can be found here.
542 questions
10
votes
1 answer

Edit style of grid.arrange title. Bold, italic etc. R

I am creating a multi plot in R using grid.arrange, and wanted to change my title so that it is bold (and italic if possible). As this is a general question, I will not include the code for my plots, but the code I am using to make my multi plot…
sym246
  • 1,836
  • 3
  • 24
  • 50
10
votes
1 answer

Merging Table Header Cells Using tableGrob

I am currently creating a table image using: SummaryTable <- data.frame( index, xa, xb, ya, yb, za, zb ) names(SummaryTable) <- c("Index", "Main X Sub A", "Main X Sub B", …
Scott
  • 446
  • 4
  • 16
10
votes
2 answers

Remove white space between plots and table in grid.arrange

I would like to remove the large spacing that is inserted by default between the plots and the table in a grid.arrange, as shown in the MWE hereafter: require(ggplot2) require(gridExtra) list1=data.frame(mtcars[1:3, ]) # Dummy data p1 =…
JohnBee
  • 1,720
  • 1
  • 15
  • 19
10
votes
3 answers

Change text color for cells using TableGrob

Is there a way to individually change the color of the text of a cell when using tableGrob and ggplot2? For instance in the code below it'd be great if the cell with 1 could be blue and the cell with 2 could be red, with 3:8 all…
user3667133
  • 147
  • 2
  • 9
10
votes
1 answer

How to use empty space produced by facet_wrap?

I have a faceted plot that forms an n x m grid. By design, the last (bottom-right) cell is always empty, so I'd like to utilize the extra space by adding another ggplot object. My current solution relies on low-level viewport approach, which is not…
tonytonov
  • 25,060
  • 16
  • 82
  • 98
10
votes
2 answers

Align edges of ggplot choropleth (legend title varies)

I am attempting to align the left and right edges of 4 ggplot choropleth maps using this method. I am unable to do this though. Original plot: library(ggplot2); library(gridExtra) crimes <- data.frame(state = tolower(rownames(USArrests)),…
Tyler Rinker
  • 108,132
  • 65
  • 322
  • 519
9
votes
1 answer

How To Edit Common Legend Title In ggarrange?

How do I edit a common legend title (make it bold font and enlarge the font size) using ggarrange? Based on the six plots I have (p1 to p6), I thought the following would work: p6 <- p6 + theme(legend.title = element_text(size = 15, face =…
shsh
  • 684
  • 1
  • 7
  • 18
9
votes
1 answer

Only grobs allowed in gList

All -- There are several other questions on this exact topic, but none of them addresses the problem I am facing. Here is a simple snippet of code. Can anyone advise what the issue here is please? > grid.arrange(plot(rnorm(1000)),hist(rnorm(1000)),…
skafetaur
  • 143
  • 1
  • 1
  • 7
9
votes
3 answers

Cannot disable R markdown output from gridExtra (additional comment)

In my r markdown report i use 2 chunks. First: ```{r, include = FALSE, echo=FALSE, results='asis'}``` Where i load all packages and do computation. And second {r, fig.margin = TRUE, fig.width=10, fig.height=4.5, echo=FALSE, results='asis',…
M. Siwik
  • 486
  • 7
  • 17
9
votes
1 answer

how to give a title to each column created with grid.arrange() in R?

Does anyone know if it is possible to give a title at each column of graphs created with grid.arrange()? I know that is possible to give an overall title and a title to each graph but I would need only a column title. Thank you very…
coolwinter
  • 111
  • 1
  • 3
9
votes
2 answers

ggplot2: multiple plots in a single row with a single legend

I want a combined plot of two plots + their legend like this: library(ggplot2) library(grid) library(gridExtra) dsamp <- diamonds[sample(nrow(diamonds), 1000), ] p1 <- qplot(price, carat, data=dsamp, colour=clarity) p2 <- qplot(price, depth,…
mts
  • 2,160
  • 2
  • 24
  • 34
9
votes
3 answers

using ggsave and arrangeGrob after updating gridExtra to 2.0.0

since I read a lot similar question on stackoverflow so far, I couldn't find a good solution without updating ggplot2 to the development version. My problem, I have several scripts which use arrangeGrob to create combined graph out of individual…
drmariod
  • 11,106
  • 16
  • 64
  • 110
9
votes
2 answers

How can I add a title to a tableGrob plot?

I have a table, and I want to print a title above it: t1 <- tableGrob(top_10_events_by_casualties, cols=c("EVTYPE", "casualties"), rows=seq(1,10)) grid.draw(t1) A similar question was asked here: Adding text to a grid.table plot I've tried…
Nate Reed
  • 6,761
  • 12
  • 53
  • 67
9
votes
1 answer

gridExtra Colour different rows with tableGrob

I have a question regarding tableGrob/grid.table from the gridExtra package. Using the regular parameter settings, it is straightforward to colour alternate rows. However, I was hoping that it might be feasible to get a bit more control over the…
SauceCode
  • 287
  • 1
  • 3
  • 9
9
votes
2 answers

How to control plot width in gridExtra?

Possible Duplicate: left align two graph edges (ggplot) I am trying to put two plots produced with ggplot on the same page, top and bottom, so that their widths are the same. The data is from the same time series, x axis being time, so it is…
user443854
  • 7,096
  • 13
  • 48
  • 63
1 2
3
36 37