如何增加表的大小,以便它占用所有可用的空间,也就是说,没有空白。
另外-如何删除表的行名?
谢谢
dat = data.frame(x = c(1,2,4), y = c(12,3,5),z = c(5,6,7))
p =ggplot(dat, aes(x=x, y = y))+geom_point()+geom_line()
library(gridExtra)
t = tableGrob(dat)
rownames(t) =NULL
t$widths <- unit(rep(1/ncol(t), ncol(t)), "npc")
grid.arrange(t, p,p,nrow = 1)发布于 2017-03-08 21:03:49
我更新了你的密码。重要的部分是tableGrob的tableGrob选项和t$heights的设置。你可能需要调整一下这个才能符合你的口味。
library(gridExtra)
library(ggplot2)
dat <- data.frame(x = c(1, 2, 4), y = c(12, 3, 5), z = c(5, 6, 7))
p <- ggplot(dat, aes(x = x, y = y)) +
geom_point() +
geom_line()
t <- tableGrob(dat, rows = NULL) # notice rows = NULL
t$widths <- unit(rep(1 / ncol(t), ncol(t)), "npc")
t$heights <- unit(rep(1 / nrow(t), nrow(t)), "npc") # new
grid.arrange(t, p, p, nrow = 1)

https://stackoverflow.com/questions/42681649
复制相似问题