R语言画Venn图

  • Post author:
  • Post category:其他


一、画Venn diagram

1、依赖包

library(venn)

2、安装venn包

(1)方式一:install.packages(venn)

(2)方式二:在

https://cran.r-project.org/src/contrib/Archive/

下载离线安装包,然后通过Rstudio->Tools->Install Packages->Browse选中本地离线安装包

3、画venn图

library(venn)

# 随机初始化数据集
rand_1 <- sample(1:1000, 400, replace = FALSE);
rand_2 <- sample(1:1000, 600, replace = FALSE);
rand_3 <- sample(1:1000, 350, replace = FALSE);
rand_4 <- sample(1:1000, 550, replace = FALSE);
rand_5 <- sample(1:1000, 375, replace = FALSE);
rand_6 <- sample(1:1000, 200, replace = FALSE);

dataForVennDiagram <- list(
  rand_1,
  rand_2,
  rand_3,
  rand_4,
  rand_5,
  rand_6
  )

# 画venn diagram
venn(
  dataForVennDiagram, 
  snames = c("r-1", "r-2", "r-3", "r-4", "r-5", "r-6"),  # 重命令
  zcolor = "style",      # add color
  opacity = 0.25, 
  ellipse = F
  )

4、Venn效果图


注意:画出这种效果一般要求集合至少6个,如果集合小于5个,美观度没有这个好



版权声明:本文为qq_34950042原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。