Would anyone know how to reduce the distance between the keys of the size legend?
There's no need to adjust the distance of the other (color) legend.
BTW, abbreviated code looks like this:
data %>%
ggplot( aes(x=x, y=y, size=z, color=c, alpha=d))+
geom_point()+
scale_size_area(name="Cumulative excess deaths (thousands)",
max_size = 70, limits=c(NA, 10000),
breaks=c(1, 10, 100,500,1000, 5000))+
geom_abline(slope=1, intercept = 0, size=0.2)+
scale_color_manual(name="World Bank Income group")+
scale_alpha_manual(values=c(0.55,0.2))+
labs(...)+
theme_bw()+
theme(
plot.margin = margin(0.5, 0.2, 0.5, 0.5, "cm"),
plot.background = element_rect(size = 1),
plot.caption.position="plot",
legend.position="right",
legend.box.margin = margin(2,0,0,0, "cm"),
legend.title=element_text(size=8,color="black", hjust=0),
legend.text =element_text(size=8,color="black"),
legend.spacing = unit(-0.5, "cm"),
legend.key.size = unit(1,"line"),
panel.grid.minor = element_blank(),
panel.grid.major.x = element_blank(),
panel.border = element_blank())+
coord_cartesian(clip = 'off')+
guides(alpha=FALSE)+
guides(size=guide_legend(override.aes=list(shape=1),order=1),
color = guide_legend(override.aes = list(size=6, alpha=0.55),
order=2))