UpSetR sets.bar 交互不同的颜色及其集合交叉点

UpSetR sets.bar interacting different color and its sets intersections

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

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

UpSetR group by color set

Use a color palette for matrix points in UpSetR

blog post

谢谢

您可以使用 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'
)