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
16
votes
1 answer

R suppressing rownames in grid table

I can produce a table with gridExtra: eg: library(gridExtra) grid.table(head(iris)) But this produces a rownames column 1:6. Is there a way to be able to suppress the rownames column so that it does not appear in the table? Thank you for…
adam.888
  • 7,686
  • 17
  • 70
  • 105
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,392
  • 3
  • 22
  • 38
13
votes
1 answer

How can I remove rownames in gridExtra::tableGrob?

I would like to plot a table with ggplot, however, I cannot seem to manage to lose the row.names. I have tried: row.names(cov_table_a)<-NULL # outside the plot row.names = FALSE # inside the annotation_custom This is my…
T. BruceLee
  • 501
  • 4
  • 16
13
votes
6 answers

print to pdf file using grid.table in r - too many rows to fit on one page

I'm trying to output a dataframe of about 40 rows and 5 columns to a .pdf file using grid.table in gridExtra package of R. However, 40 rows is too long for a page so the .pdf file only shows part of the dataframe. I want to know if I can print two…
user2267978
  • 131
  • 1
  • 1
  • 3
13
votes
3 answers

R adding a datatable to a ggplot graph using viewPorts : Scaling the Grob

I'm trying to add a data-table to a graph made in ggplot (similar to the excel functionality but with the flexibility to change the axis its on) I've had a few goes at it and keep hitting a problem with scaling so attempt 1)…
Tahnoon Pasha
  • 5,848
  • 14
  • 49
  • 75
12
votes
1 answer

force a regular plot object into a Grob for use in grid.arrange

b <- ggplot(cars,aes(x=speed,y=dist))+geom_line() grid.arrange( b, plot(cars), ncol=1 ) gives me the following error Error in gList(list(grobs = list(list(x = 0.5, y = 0.5, width = 1, height = 1, : only 'grobs' allowed in…
Chapo
  • 2,563
  • 3
  • 30
  • 60
12
votes
1 answer

store arrangeGrob to object, does not create printable object

I want to save, but not print (for now), a bunch of ggplot()s into a grid (via arrangeGrob(), correct?), then print and retrieve them later. This is a reboot of an existing question. Strangely, that answer does not work, and I have no idea why. I am…
maxheld
  • 3,963
  • 2
  • 32
  • 51
12
votes
2 answers

Store output from gridExtra::grid.arrange into an object

I am placing multiple plots into one image using gridExtra::grid.arrange and would like to have the option of saving the combined plot as an object that could be returned from within a function as part of a list of returned objects. Ideally, I…
Benjamin
  • 16,897
  • 6
  • 45
  • 65
11
votes
2 answers

How to perfectly align an unequal number of plots (ggplot2,gridExtra)

I would like to perfectly align these plots : Here is the R code : library(tidyverse) library(gridExtra) groupes <- tribble(~type, ~group, ~prof, ~var, 1,1,1,12, 1,1,2,-24, 1,2,1,-11, …
user1788720
  • 327
  • 2
  • 11
11
votes
1 answer

grid.arrange ggplot2 plots by columns instead of by row using lists

I want create a multiplot of ggplot2 plots from a list using grid.arrange but arrange them by columns before doing it by rows. gg_list1 <- list(qplot(mpg, disp, data = mtcars), qplot(hp, wt, data = mtcars), …
Bonono
  • 827
  • 1
  • 9
  • 18
11
votes
1 answer

R - how to allocate screen space to complex ggplot images

I am trying to write a script that produces four different plots in a single image. Specifically, I want to recreate this graphic as closely as possible: My current script produces four plots similar to these but I cannot figure out how to allocate…
Slavatron
  • 2,278
  • 5
  • 29
  • 40
11
votes
1 answer

grid.table and tableGrob in gridExtra package

I am trying to format the table using gridExtra package. The gridExtra package I have is 2.0 and R version is 3.2.1 I was going through answers here on stackoverflow about the formatting and the suggested options seem to work only with older version…
ashishkul
  • 405
  • 2
  • 6
  • 17
11
votes
2 answers

Arrange ggplots together in custom ratios and spacing

I am trying to combine n number of barplots with one common label plot at the bottom. My problem is that grid.arrange combines the two plots in 50%-50%. I am looking for something like the layout matrix where you can specify 4 slots and first 3 to…
mindlessgreen
  • 11,059
  • 16
  • 68
  • 113
11
votes
2 answers

reduce space between grid.arrange plots

I asked a question HERE about grid arrange and got a terrific response. I want to reduce the space between plots now but get an error. First I present the code that works and then the error code (what I tried). I can't actually find grid.arrange…
Tyler Rinker
  • 108,132
  • 65
  • 322
  • 519
10
votes
2 answers

R: Using marrangeGrob to make pdf results in blank first page

I'm making some pdf files with multiple graphs on each page, and, when I use marrangeGrob from the gridextra package to make those graphs, the first page is always blank. How can I make the plots start on the first page? Here's some example…
shirewoman2
  • 1,842
  • 4
  • 19
  • 31
1
2
3
36 37