【问题标题】:Is there a way to omit variables with NA values from facet wrap plots?有没有办法从 facet wrap 图中省略具有 NA 值的变量?
【发布时间】:2021-10-17 02:55:17
【问题描述】:
# A tibble: 8 × 4
  measurement   log2_fc locus  operon
  <chr>           <dbl> <chr>  <chr> 
1 transcriptome     1   PA3552 arn   
2 transcriptome     1.5 PA3553 arn   
3 proteome         NA   PA3552 arn   
4 proteome          2   PA3553 arn   
5 transcriptome     2.5 PA1179 opr   
6 transcriptome     3   PA1180 opr   
7 proteome         NA   PA1179 opr   
8 proteome         NA   PA1180 opr

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

plot + facet_wrap(~operon, ncol=2)

我正在使用上面的代码创建一个图,比较通过两种不同测量方法获得的基因的 log2_fc。我想通过基因所属的操纵子将情节分开,但我只想让操纵子中的基因沿着每个方面的 x 轴绘制。目前它正在创建下面的情节:

有没有办法只在 x 轴上绘制每个轨迹值一次,并且仍然用操作子分隔数据?

【问题讨论】:

  • 试试scales = "free_x" in facet_wrap

标签: r ggplot2 tibble facet-wrap


【解决方案1】:

你只需要释放 x 轴:

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

如果不指定scales = "free_x",ggplot 默认使用具有相同限制和中断的相同轴。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-01-09
    • 2011-06-12
    • 2021-11-28
    • 1970-01-01
    • 2021-03-10
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多