You need to enable JavaScript to run this app. 如何让ggplot2的facet_wrap分面仅展示对应operon下的locus作为x轴刻度?
优惠活动
大模型
产品
解决方案
定价
更多

如何让ggplot2的facet_wrap分面仅展示对应operon下的locus作为x轴刻度?

实现分面独立x轴的方法

要实现每个operon分面仅显示对应分组内的locus,只需给facet_wrap()添加scales = "free_x"参数即可,该参数会让各分面的x轴独立适配当前分面的数据集,不会加载其他operon下的locus,且同一分面内的重复locus会自动去重仅展示一次。

修改后完整代码

plot <- ggplot(data=x,aes(x=locus,y=log2_fc,color=measurement)) +
  geom_jitter()

plot + facet_wrap(~operon, ncol=2, scales = "free_x")

内容的提问来源于stack exchange,提问作者yasmin

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.07 19:45:02