如何在 R 中使用 ggarrange 减少绘图之间的间隙?

Har*_*hna 6 r ggpubr waffle-chart

我正在尝试创建一个华夫饼图,其中共有 9 个图。然而,无论我如何尝试,我都无法减少图中 3 列之间的间距。这就是我现在的情节。 华夫饼情节足球

到目前为止我使用的代码是这样的:-

fig1 <- waffle(Intvec, rows=10, size=2.0, 
           colors=c("#cb181d", "#238b45", "#0570b0", 
                    "#fec44f", "#ec7014", "#6a51a3"),
           title = "Inter")
fig1$layers[[1]]$aes_params$colour <- '#252525'
fin1 <- fig1 + theme(plot.background = element_rect(fill = "#252525", colour = "#252525")) +
theme(legend.position = "none") +
labs(y = "Serie A", main = "Inter") +
 theme(axis.title.y = element_text(color="#bdbdbd", size=18, face="bold"),
 plot.title = element_text(colour = "#ffffff", size = 20, face = "bold"))
fin1
Run Code Online (Sandbox Code Playgroud)

在使用 ggarrange 之前对其他 8 个地块执行相同的操作

fig <- ggarrange(fin1, fin2, fin3, fin4, fin5,
                 fin6, fin7, fin8, fin9,
                 nrow = 3, ncol = 3)
Run Code Online (Sandbox Code Playgroud)

有人可以帮我解决这个问题吗?

小智 2

晚了一年半......但我遇到了同样的问题。对我有用的是设置 ggplot 边距: theme(plot.margin = unit(c(0,0.2,0,1), 'lines'))

请记住,ggplot2 中的图边距顺序与基本 R 图中的图边距顺序不同:

unit(c(top, right, bottom, left), units)