我正在尝试将绘图和表格安排在一起,但是表格的顶部和侧面都被切断了。
library(ggplot2)
library(grid)
library(gridExtra)
# Generate example data
plot.data <- cbind(c(1,2,3,4,5,6,7,8,9), c(2,2,2,3,3,3,4,4,4))
colnames(plot.data) <- c("the.x", "the.y")
plot.data <- data.frame(plot.data)
p <- ggplot(plot.data, aes(x=the.x, y=the.y))
p <- p + geom_line()
table.1.data <- cbind("quitelongparametertext", seq(from=1, to=15), seq(from=21, to=35))
colnames(table.1.data) <- c("parameter", "data.1", "data.2")
table.1.data <- data.frame(table.1.data)
table.2.data <- cbind("shortertext", seq(from=1, to=3), seq(from=11, to=13), seq(from=21, to=23), seq(from=31, to=33), seq(from=41, to=43), seq(from=51, to=53))
colnames(table.2.data) <- c("parameter", "data.1", "data.2", "data.3", "data.4", "data.5", "data.6")
table.2.data <- data.frame(table.2.data)
t1 <- tableGrob(table.1.data, show.rownames=F)
t2 <- tableGrob(table.2.data, show.rownames=F)
# Print together
print(arrangeGrob(p, arrangeGrob(t1, t2, nrow=2), ncol=2, widths=c(1,1)))
绘图的文本相应地调整大小,但如何对表格进行同样的操作?