我有一个geom_point图,其中包含大量类别变量,并且有一个size
参数映射到连续变量。当我绘制图时,分类变量之间的距离太近,每个区域内的大点重叠。有什么办法可以给轴腾出一点呼吸空间,以免发生这种情况?我知道另一种解决方案是简单地使用scale_size_area(max_size = 3)
来缩小点大小的范围,但是我不希望这样做,因为这样很难区分它们。
代码如下:
plot <- ggplot(allcazfull, aes(x = Family, y = ifelse(Percentage==0,NA, Percentage), fill = Treatment, size = ifelse(Number == 0, NA,Number))) +
facet_wrap(~ Pathogen, scales = "free_x") +
geom_point(shape = 21) +
scale_fill_manual(values = alpha(c("#98fb98","#f77e17","#0d5a0d","#8d0707"),.6)) +
theme_bw() +
theme(panel.grid.major.x = element_blank(),
panel.grid.minor.x = element_blank(),
aspect.ratio = 4/1,
strip.background = element_rect(fill="white", linetype = "blank"),
strip.text = element_blank()) +
scale_x_discrete(limits = rev(levels(allcazfull$Family))) +
xlab("") +
ylab("") +
guides(fill = FALSE, size = FALSE) +
coord_flip()
plot