在 R 中的 grid.arrange 中调整标签到 table 的距离

Adjusting distance from labels to table in grid.arrange in R

我在 grid.arrange 中找不到如何调整标签到 table 的距离:

distances_lsit = c(25,50,75,100) 
category_lsit = 0:5 
damage_table = matrix(NA, nrow=length(distances_lsit), ncol=length(category_lsit))
damage_table[1,] = c(10,25,50,75,100,100)
damage_table[2,] = c(5,10,25,50,75,100)
damage_table[3,] = c(2.5,5,10,25,50,75)
damage_table[4,] = c(0,2.5,5,10,25,50)
rownames(damage_table) = distances_lsit
colnames(damage_table) = category_lsit
table_scale = tableGrob(damage_table)

grid.arrange(table_scale, top = "Label 1", left = "Label 2")

生成 table 如下:

有没有办法把它粘到table上?预先感谢您的帮助。

您应该使用下一个参数来找到最佳位置

  • 身高;
  • 宽度;
  • textGrob.

例如,这个:

grid.arrange(table_scale, top = textGrob("Really looks \n better now?", x = 0, hjust = -1), left = "I'm near,\n my man", heights = c(2,1), widths = c(1,1.5))

给你看这个: