I have been battling with this problem for sometime now. I want to reduce the space between a ggplot and a table using grid.arrange. I looked at various threads, searched on the web, tried various things, but I cannot reduce the space between two plots if they are in one column. (yes, it needs to be a pie chart though a table provides better information)
Here's my sample code.
fruits <- data.frame(Type = c("Oranges", "Apples"), Quantity = c(200, 500))
g <- ggplot(fruits, aes(x = factor(1), y = Quantity, fill = Type)) + geom_bar(position = "fill", stat = "identity", width = 1) + coord_polar(theta = "y")
g <- g + labs(x = NULL, y = NULL) + theme(axis.ticks = element_blank(), axis.text = element_blank(), panel.background = element_rect(fill = "white", colour = "white"), legend.position = "none")
g <- g + theme(plot.margin = unit(c(0,0,0,0), "lines"))
gtablegrob <- tableGrob(fruits, show.rownames = FALSE, gpar.coretext = gpar(fontsize = 10), par.coltext = gpar(fontsize = 10), gpar.rowtext = gpar(fontsize = 10), gpar.corefill = gpar(fill = "white", col = "white"))
grid.arrange(g, gtablegrob, nrow = 2)
The other similar thread provides solution on widths, but I could not find documentation on heights.