【问题标题】:UpSetR sets.bar interacting different color and its sets intersectionsUpSetR sets.bar 交互不同颜色及其集合交点
【发布时间】:2021-04-14 15:24:04
【问题描述】:

您好,我正在创建扰乱图,但无法弄清楚如何绘制数据,如下图所示

我看到不同的情节与此相似但不一样,任何人都可以建议我一个简单的方法,并且看到一些线程无法根据我上面的图像类型输出复制一些

UpSetR group by color set

Use a color palette for matrix points in UpSetR

blog post

谢谢

【问题讨论】:

  • 您会考虑使用ComplexUpset 来代替答案,还是仅寻找UpSetR 解决方案?
  • @krassowski 谢谢你的回复,一切都会好起来的
  • @krassowski 我尝试了 ComplexUpset R 但无法得到我想要的东西,请你帮我弄清楚

标签: r upsetr


【解决方案1】:

您可以使用 ComplexUpset 1.3 或更高版本重现此图。

准备数据集:

movies = ggplot2movies::movies
movies[movies$mpaa == '', 'mpaa'] = NA 
movies = movies[complete.cases(movies), ]

还有情节:

upset(
  movies,
  c('Action', 'Comedy', 'Drama'),
  queries=list(
    upset_query(set='Action', fill='orange'),
    upset_query(set='Comedy', fill='blue'),
    upset_query(set='Drama', fill='coral3')
  ),
  base_annotations=list(
    'Intersection size'=(
        intersection_size(
        bar_number_threshold=1,  # show all numbers on top of bars
        width=0.5,   # reduce width of the bars
      )
      # add some space on the top of the bars
      + scale_y_continuous(expand=expansion(mult=c(0, 0.05)))
      + theme(
          # hide grid lines
          panel.grid.major=element_blank(),
          panel.grid.minor=element_blank(),
          # show axis lines
          axis.line=element_line(colour='black')
      )
    )
  ),
  stripes=upset_stripes(
    geom=geom_segment(size=12),  # make the stripes larger
    colors=c('grey95', 'white')
  ),
  # to prevent connectors from getting the colorured
  # use `fill` instead of `color`, together with `shape='circle filled'`
  matrix=intersection_matrix(
      geom=geom_point(
        shape='circle filled',
        size=3.5,
        stroke=0.45
      )
  ),
  set_sizes=(
    upset_set_size(geom=geom_bar(width=0.4))
    + theme(
      axis.line.x=element_line(colour='black'),
      axis.ticks.x=element_line()
    )
  ),
  sort_sets='ascending',
  sort_intersections='ascending'
)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-06-05
    • 2015-09-17
    • 1970-01-01
    • 1970-01-01
    • 2021-01-31
    • 2016-09-24
    • 2022-01-19
    • 2017-05-09
    相关资源
    最近更新 更多