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.
500 questions
155
votes
9 answers

Add a common Legend for combined ggplots

I have two ggplots which I align horizontally with grid.arrange. I have looked through a lot of forum posts, but everything I try seem to be commands that are now updated and named something else. My data looks like this; # Data plot 1 …
jO.
  • 2,834
  • 7
  • 25
  • 33
151
votes
7 answers

Saving grid.arrange() plot to file

I am trying to plot multiple plots using ggplot2, arranging them using grid.arrange(). Since I managed to find someone describing the exact problem I have, I have quoted from the problem description from link: When I use ggsave() after…
I Like to Code
  • 6,111
  • 12
  • 32
  • 40
108
votes
9 answers

Left align two graph edges (ggplot)

I'm using ggplot and have two graphs that I want to display on top of each other. I used grid.arrange from gridExtra to stack them. The problem is I want the left edges of the graphs to align as well as the right edges regardless of axis labels. …
Tyler Rinker
  • 99,090
  • 56
  • 292
  • 477
52
votes
2 answers

Specify widths and heights of plots with grid.arrange

I have three plots and I try to combine them with grid.arrange. The last plot should have a smaller height than the first two plots and all the plots should have the same width. A working example: p1 <- qplot(mpg, wt, data=mtcars) p2 <- p1 p3 <- p1…
Chika
  • 1,155
  • 2
  • 11
  • 20
49
votes
2 answers

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.
moadeep
  • 3,522
  • 9
  • 41
  • 66
42
votes
2 answers

grid.arrange from gridExtras exiting with "only 'grobs' allowed in 'gList'" after update

I just updated R, R Studio, and a bunch of packages including ggplot2 and gridExtras on my Mac. Now gridExtras is failing in basic plotting with the error: "only 'grobs' allowed in "gList"" Here's some code that should work but does…
Mike Shea
  • 767
  • 1
  • 7
  • 13
23
votes
2 answers

How to adjust the Font Size of tableGrob

Any idea how to adjust the font size of a tableGrob? I am using gridExtra 2.0.0, which seem to be very different previous version 0.9.3. g <- tableGrob(mtcars) grid.arrange(g) I am looking to adjust the font size of the text in the table, header,…
user2103970
  • 633
  • 2
  • 8
  • 14
22
votes
5 answers

Multiple ggplots of different sizes

It's relatively simple using grid.arrange in the gridExtra package to arrange multiple plots in a matrix, but how can you arrange plots (the ones I'm working on are from ggplot2) when some plots are intended to be larger than others? In base, I can…
Hugh
  • 13,468
  • 6
  • 48
  • 90
21
votes
3 answers

Plot over multiple pages

I have the facet_wrap function to make multiple graphs (n=~51) but they all appear on one page. Now after searching, I found out that ggplot2 can't place graphs on multiple pages. Is there a way to do this? I looked at this question (Multiple…
LearningTheMacros
  • 351
  • 1
  • 2
  • 7
18
votes
1 answer

ggplot2: Define plot layout with grid.arrange() as argument of do.call()

I want to obtained an unbalanced grid of plots such as require(ggplot2) require(gridExtra) df <- data.frame(value1 = rnorm(200), value2 = rnorm(200), value3 = rnorm(200), value4 = rnorm(200)) p1…
CptNemo
  • 5,805
  • 14
  • 46
  • 95
17
votes
1 answer

The perils of aligning plots in ggplot

QUESTION How do you combine separate plots (ggplot2), with different y-axis and different plot heights, yet retain alignment? DETAIL When combining plots with grid.arrange (method1), with different y-axis units, they do not align. One way around…
wab
  • 675
  • 5
  • 15
16
votes
2 answers

gridExtra 2.0.0 change title size

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…
Cyrus Mohammadian
  • 4,196
  • 4
  • 26
  • 50
16
votes
4 answers

ggplot2 and gridExtra: completely remove strip in facet_grid - not just invisible

I have two graphs that I'm placing one above the other, in the following way: library(ggplot2) library(gridExtra) p1 <- ggplot(mtcars, aes(mpg, wt)) + geom_point() p2 <- ggplot(mtcars, aes(mpg, wt)) + geom_point() p2 <- p2 + facet_grid(cyl ~…
15
votes
1 answer

How to plot barchart onto ggplot2 map

I have found similar answers to questions like this one, but most of them are using packages rworldmap, ggmap, ggsubplot or geom_subplot2d. See for example here or here. I'd like to know how I can plot other ggplot-objects such as a bar-chart onto…
Thomas
  • 1,320
  • 1
  • 18
  • 36
13
votes
1 answer

Margins between plots in grid.arrange

I dont seem to be able to find a solution as to how to increase the space between two plots with grid.arrange. I find no clue as to how to proceed. I dont want to change the size of the plots or anything like that. grid.arrange(plot1, plot2,…
augusti
  • 331
  • 2
  • 4
  • 15
1
2 3
33 34