r - UpSetR sets.bar 交互不同颜色及其集合交点
问题描述
我看到了与此类似但不相同的不同情节,任何人都可以建议我一种简单的方法吗,并且根据我上面的图像类型输出,看到一些线程无法重现一些
谢谢
解决方案
您可以使用 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'
)
推荐阅读
- c++ - 在绘制命令之间每帧设置任意数量的剪刀
- php - Cakephp如何创建无表模型?
- haskell - 如何在 Haskell 中融合两个相同类型的枚举?
- javascript - Redis set 命令成功但数据库未更改
- angular - BehaviorSubject:为什么不使用 next 就可以工作
- c - C中字符总和的问题
- macos - 如何添加将使用单个选定文件的 Finder 服务,在其上执行 shell 脚本,然后将其显示为对话框窗口?
- r - 像循环一样保存数字,直到数据帧结束
- apache-poi - 使用 Apache POI 在 XLSX 中为行高添加填充
- python - _fstream->is_open() 在运行 gem5 python 脚本时出现错误