You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

ComplexUpset中按集合颜色手动设置交集矩阵点的颜色

解决方法

你只需要在scale_color_manual()中添加guide = "none"参数,关闭额外生成的color映射图例即可,修改后的完整代码如下:

movies <- read.csv( system.file("extdata", "movies.csv", package = "UpSetR"), header=T, sep=";" )

ComplexUpset::upset(movies, colnames(movies)[3:5], name='genre', width_ratio=0.1, 
  matrix=(intersection_matrix(geom=geom_point()) +
            scale_color_manual(
              values = c('Action'='red', 'Adventure'='blue', 'Children'='yellow'),
              guide = "none" # 关闭额外的颜色图例
            )), 
  queries=list(upset_query(set='Action', fill='red'),
               upset_query(set='Adventure', fill='blue'),
               upset_query(set='Children', fill='yellow')))

多余图例是scale_color_manual默认生成的颜色映射图例,添加参数禁用后不会影响实际的点颜色匹配效果,交集点的连接线段默认保持黑色,无需额外配置。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.10.03 13:48:06