Trim off empty cells.

rect <- rectGrob(gp = gpar(fill = "black"))
base <- gtable(unit(c(2, 2, 2), "cm"), unit(c(2, 2, 2), "cm"))

center <- gtable_add_grob(base, rect, 2, 2)
plot(center)

plot of chunk gtable_trim

plot(gtable_trim(center))

plot of chunk gtable_trim

col <- gtable_add_grob(base, rect, 1, 2, 3, 2)
plot(col)

plot of chunk gtable_trim

plot(gtable_trim(col))

plot of chunk gtable_trim

row <- gtable_add_grob(base, rect, 2, 1, 2, 3)
plot(row)

plot of chunk gtable_trim

plot(gtable_trim(row))

plot of chunk gtable_trim