我想结合facet_wrap和cord_flip,但是当我这样做时,我会在每个方面重复轴类别。
这是一些演示数据。
demo_data = data.frame(locus = c(paste0("locus_", rep(1, 5)),
paste0("locus_", rep(2, 5)),
paste0("locus_", rep(3, 5)),
paste0("locus_", rep(4, 5)),
paste0("locus_", rep(5, 5))),
sample = rep(paste0("sample_", seq(1:5))),
value = sample(100, 25)) %>%
mutate(ci_upper = value + 10,
ci_lower = value - 10)
当我绘制它时,原始x轴上的值为sample_1到sample_5。当我翻转坐标时,样本 1-5 在每个方面都会重复,这使得绘图看起来文本过于混乱。我希望它们只出现在左侧的面上,就像通常在facet_wrap 中发生的那样。
ggplot(demo_data, aes(x = sample, y = value)) +
geom_point() +
geom_errorbar(aes(ymin = ci_lower,
ymax = ci_upper)) +
facet_wrap(~ locus, scales = "free") +
coord_flip()
有什么想法可以实现这一目标吗?
我尝试在这里搜索,但找不到任何相关内容