I\'m trying to add a data-table to a graph made in ggplot (similar to the excel functionality but with the flexibility to change the axis its on)
I\'ve had a few goe
You can try the new version of tableGrob; the resulting gtable width/height can be set to a specific size (here equi-distributed npc units)
library(ggplot2)
library(gridExtra)
library(grid)
tg <- tableGrob(head(iris), rows=NULL)
tg$widths <- unit(rep(1/ncol(tg),ncol(tg)),"npc")
tg$heights <- unit(rep(1/nrow(tg),nrow(tg)),"npc")
qplot(colnames(iris), geom="bar")+ theme_bw() +
scale_x_discrete(expand=c(0,0)) +
scale_y_continuous(lim=c(0,2), expand=c(0,0)) +
annotation_custom(ymin=1, ymax=2, xmin=-Inf, xmax=Inf, tg)