I have a grobTable and a ggplot2 object and I want to plot them together using grid.arrange. The issue is that the resulting plot has always a whitespace above the two
library(grid)
library(gridExtra)
library(data.table)
library(ggplot2)
tmp = data.table(Group1 = c("C", "B", "A", "C", "B", "A", "C",
"B", "A"), Group2 = c("C", "C", "C", "B", "B", "B", "A", "A",
"A"), N = c(1949L, 7L, 403L, 64L, 13L, 73L, 347L, 13L, 2131L))
tmp2 = structure(c(0.84, 0.83, 0.84, 0.83, 0.83, 0.54, 0.09, 1, 0.39,
0.09, 0.83, 0.86, 0.81, 0.82, 0.86), .Dim = c(5L, 3L), .Dimnames = list(
c("d", "p", "e", "x", "c"), c("h", "g", "p")))
tmp_plot = ggplot(data = tmp, aes(x = Group1 , y = Group2))+
geom_tile() +
geom_text(aes(label = N)) +
coord_fixed(ratio=1) +
guides(fill=FALSE) +
theme(plot.margin=unit(c(0,0,0,0), "mm"))
t <- tableGrob(tmp2, theme = ttheme_default(padding=unit(c(0, 0), "mm")))
grid.arrange(t, tmp_plot, ncol=2)
I have tried the following suggestions but nothing has worked so far: removing all the space between two ggplots combined with grid.arrange , R gridExtra 2.0.0: tableGrob vertical and horizontal padding
Any advice as to how to touch (and reduce) this space?