我想结合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()
有什么办法可以做到这一点吗?
我试着在这里搜索,但找不到任何相关的东西