I was able to figure out the answer to this question. I was able to use the solution provided by '42-' in Text alignment and font size in gtable
Changing his code fragment and adding it to the end of the referenced question.
g$grobs[] <-
lapply(g$grobs[],
function(x) modifyList( x, list(gp=list(fontsize=25, cex=1) ) ) )
The full code would be:
library(gtable)
library(grid)
library(gridExtra)
library(zoo)
data(iris)
iris <- iris[1:4, 1:3]
rownames(iris) <- as.character(as.yearmon(
seq(as.Date("2000/1/1"), as.Date("2000/4/1"), by = "month")))
iris$RankColumn <- 1:nrow(iris)
# a simple function to scale each row or column to the range [0, 1]
# will convert characters to numerics if in a sensible format
norm <- function(x, mar=2) {
rnames <- rownames(x)
x <- apply(x, 2, as.numeric)
x <- apply(x, mar, function(y){(y-min(y))/(max(y)-min(y))})
rownames(x) <- rnames
x
}
# function to pad with zero
# by default does not pad integers
zeropad <- function(x, nz=1, exc.int=TRUE) {
if (is.integer(x) & exc.int) {
x
} else {
sprintf(paste0("%.", nz, "f"), x)
}
}
bluecol <- colorRamp(c("#3366EE", "#AABBFF", "#DDDDFF"))(norm(iris))
bluecol <- rgb(bluecol[, 1], bluecol[, 2], bluecol[, 3], max=255)
tt <- ttheme_default(core=list(bg_params=list(fill=bluecol)))
# convert floats to zero-padded characters
iris[1:ncol(iris)] <- sapply(iris, zeropad, 2)
g <- tableGrob(iris, theme=tt)
g <- gtable_add_grob(g,
grobs = rectGrob(gp = gpar(fill = NA, lwd = 2)),
t = 2, b = nrow(g), l = 1, r = ncol(g))
g <- gtable_add_grob(g,
grobs = rectGrob(gp = gpar(fill = NA, lwd = 2)),
t = 1, l = 1, r = ncol(g))
g$grobs[] <-
lapply(g$grobs[],
function(x) modifyList( x, list(gp=list(fontsize=25, cex=1) ) ) )
plot.new()
grid.draw(g)