Questions tagged [grob]

stands for **gr**aphical **ob**ject, the generic drawing component in the grid framework of R graphics. Grobs can be very primitive, such as text, rectangles, lines, or complex objects such as full plots built up from many lower-level components.

The recommended grid package is included in every distribution of the R software. As such, it provides a low-level framework for building up all kinds of static graphics. The core component of grid-based graphics is a grob, which in its most basic form is a generic class of objects that describe a graphical component. The most basic grobs are simple shapes such as pointsGrob, polygonGrob, etc., but new objects can be derived from those primitive objects, and are often assembled into a grob tree, or gTree, which holds together multiple shapes together with a specific layout.

Examples of high-level, complex grobs are the complete plots generated by the ggplot2 and lattice packages.

146 questions
2
votes
1 answer

Row names in tableGrob are cut off when using row.just = "left

Can anyone solve why the cutoff of row names occurs for me? It is independent of the length of the string wrap. Specifying row.just = "center" does not cut off the row names. x <- data.frame(row.names=paste("Very very name goes in here somewhere yep…
Alex
  • 971
  • 4
  • 15
  • 28
2
votes
1 answer

How to theme a tableGrob object from gridExtra in r

I would like to re-use a theme/template/default for a tableGrob object from the gridExtra package in r. library(gridExtra) tableGrob(df, cols = c("Custom Name", "Custom Name2"), show.rownames = FALSE, h.even.alpha = 0) tableGrob(df2,…
JasonAizkalns
  • 20,243
  • 8
  • 57
  • 116
2
votes
2 answers

How can one copy-paste local png files to a word document using R?

I have ~10,000 png images saved neatly in different files on my PC. I want to write a function that does something like go to a particular folder and iteratively copy-pastes all the png files in that folder to a word document. Is this possible in…
Frikster
  • 2,755
  • 5
  • 37
  • 71
2
votes
0 answers

How to use lapply with ggplotGrob()?

I am trying to apply the function ggplotGrob() to a list of ggplots using lapply but can't seem to be able to obtain a list of grob objects out of it. For this project, a variable number of plots are generated based on user input, and I need a…
robanche
  • 63
  • 4
1
vote
0 answers

Placing a ggplot function on top of a png/jpg image in R

I am stuck at this point. Let me elaborate in detail the situation and the problem I am facing. I created a function, named crown_height_recons_2d() and it is stored in GitHub. This function aims at reconstructing the outline of enamel in different…
antecessor
  • 2,688
  • 6
  • 29
  • 61
1
vote
0 answers

Change the column width on a tableGrob using ttheme_minimal

I'm trying to build a table using tableGrob in gridExtra and can't figure out how to set the column with. I am using ttheme_minimal(base_size = 25) to set the size of the text, but I can't seem to find a way in that function to se the column widths.…
Sam Hoppen
  • 355
  • 2
  • 9
1
vote
1 answer

ggplot2 facet_wrap strip.position different for last column

I would like to have strip.position = "right" for the last column in my facet_wrap. I attempted to implement this SO answer, but did not have any luck. Data dta <- structure(list(month = structure(c(1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 3L,…
LMc
  • 12,577
  • 3
  • 31
  • 43
1
vote
2 answers

How to combine two plot lists (made of ggplot graphs) in a single plot list?

I have two plot lists, each one with 3 graphs, made with ggplot: plot_list1: plot_list2: I would like to combine them in a single list, where all graphs are present, as this one: I have thought to create plot_list1 as you see above, and…
EmaK
  • 154
  • 1
  • 9
1
vote
1 answer

Grobs are not plotted at all or in wrong position

I am having trouble understanding how grobs are being placed into the plotting area. Here's an example of what I mean. Let's assume I have the following plot. library(tidyverse) p <- mpg %>% ggplot(aes(year)) + geom_bar() p I understand that…
AlbertRapp
  • 408
  • 2
  • 9
1
vote
0 answers

Arranging multiple plot in different layouts on multiple pages

I'm using R and trying to create a pdf file in the following structure: Given two lists of plots - reportMain, reportExtra, I would like to create one pdf file, where at the first pages appears reportMain's plots, 4 plots in page in 2X2 matrix. and…
Gil
  • 11
  • 2
1
vote
1 answer

How to auto-adjust size of ggarrange (ggplotGrob + ggplot graphs) into a pdf in R?

I would like to save as pdf a combi of three graphs - one ggplot and two ggplotGrob. With the codes I am trying, the figures are on top of each other. library(ggplot2) library(condformat) library(ggpubr) data(iris) graph1 <- ggplot(data=iris,…
CamillaM
  • 23
  • 5
1
vote
1 answer

Ho to highlight conditional values in a two way table graphing with TableGrob in R?

I would like to graph a table in R where I highlight a value with a condition of 'less than 2' in Red, for example. Any help on how I can do this? data(iris) iris <- iris[1:4, 1:3] rownames(iris) <- as.character(as.yearmon( …
CamillaM
  • 23
  • 5
1
vote
0 answers

Execution of single elements in grid.arrange / general functionality of grid.arrange (gridExtra)

I have a general question about the functionality of grid.arrange (gridExtra) and possible improvement potentials. Using an R Shiny app, I display various outputs (ggplot2, textgrob, rasterGrob) via a grid.arrange. During execution, however, data…
Alex_
  • 189
  • 8
1
vote
1 answer

Side-by-Side Grobs Not Working with Shiny

I would like to create a Shiny document which shows two grobs alongside one another and would like the text inside each grob to be the selected value of a sliderInput. I am able to easily output two grobs side-by-side in a non-reactive context…
DJC
  • 1,491
  • 6
  • 19
1
vote
1 answer

arrange R plots: how can I arrange plots of the VIM package?

I would like to generate multiple plots using marginplot() (VIM package) and then arrange them into one big figure. I tried to use grid.arrange (grid/gridExtra package) and it did not work. The error was, that a grob was expected as input. So I…
CST
  • 207
  • 1
  • 6