0

The following is some example code provided by baptiste which shows how to modify the font size of an individual grob element.

g <- tableGrob(iris[1:4, 1:3])
find_cell <- function(table, row, col, name="core-fg"){
  l <- table$layout
  which(l$t==row & l$l==col & l$name==name)
}

ind <- find_cell(g, 3, 2, "core-fg")
ind2 <- find_cell(g, 2, 3, "core-bg")
g$grobs[ind][[1]][["gp"]] <- gpar(fontsize=15, fontface="bold")
g$grobs[ind2][[1]][["gp"]] <- gpar(fill="darkolivegreen1", col = "darkolivegreen4", lwd=5)
grid.draw(g)

How would I do this do all grobs in my table?

I have attempted using

g$grobs["gp"] <- gpar(fontsize=15, fontface="bold")

but this is not the correct syntax.

Scott
  • 446
  • 4
  • 16

1 Answers1

1

You could do it like this:

lapply(1:length(g$grobs),function(i){g$grobs[[i]]$gp$fontsize <<- 35})
grid.draw(g)
RmIu
  • 4,357
  • 1
  • 21
  • 24