首页 > 解决方案 > 如何在 R 中制作具有透明背景的 UpSet 图?

问题描述

是否可以制作具有透明背景的 UpSet 图?

我检查了文档,没有与背景颜色相关的参数。

我也尝试过直接保存为 .pdf,但实际上只有一小部分图变得透明(在 y 标签的左侧)。

library(UpSetR)

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

pdf("test.pdf", bg = "transparent")

upset(movies, order.by = "freq",
      text.scale = 2,
      point.size = 4)

dev.off()

变得透明的部分在附图中以蓝色显示,这样你就可以看到我所指的情节部分。

数字

> sessionInfo()
R version 3.6.1 (2019-07-05)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS Mojave 10.14.6

Matrix products: default
BLAS:   /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libRlapack.dylib

locale:
[1] en_GB.UTF-8/en_GB.UTF-8/en_GB.UTF-8/C/en_GB.UTF-8/en_GB.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] UpSetR_1.4.0

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.2       assertthat_0.2.1 crayon_1.3.4     dplyr_0.8.3     
 [5] plyr_1.8.4       R6_2.4.0         grid_3.6.1       gtable_0.3.0    
 [9] magrittr_1.5     scales_1.0.0     ggplot2_3.2.1    pillar_1.4.2    
[13] rlang_0.4.0      lazyeval_0.2.2   rstudioapi_0.10  labeling_0.3    
[17] tools_3.6.1      glue_1.3.1       purrr_0.3.2      munsell_0.5.0   
[21] compiler_3.6.1   pkgconfig_2.0.3  colorspace_1.4-1 tidyselect_0.2.5
[25] gridExtra_2.3    tibble_2.1.3 

谢谢。

标签: rgraphicsupsetr

解决方案


推荐阅读