维恩图的绘制方法也比较多,在线的工具也不少,本文简单简介用VennDiagram来绘制维恩图。

# 加载R包
library(VennDiagram)
library(RColorBrewer)
 
# 生成演示数据
set1 <- paste(rep("word_" , 200) , sample(c(1:1000) , 200 , replace=F) , sep="")
set2 <- paste(rep("word_" , 200) , sample(c(1:1000) , 200 , replace=F) , sep="")
set3 <- paste(rep("word_" , 200) , sample(c(1:1000) , 200 , replace=F) , sep="")

# 设置颜色
myCol <- brewer.pal(3, "Pastel2")

# Chart
venn.diagram(
        # 3个集合的list
        x = list(set1, set2, set3),
        # 定义显示标签
        category.names = c("Set 1" , "Set 2 " , "Set 3"),
        # 输出文件
        filename = 'venn_diagramm.png',
        output=TRUE,
        
        # 输出文件设置
        imagetype="png" ,
        height = 480 , 
        width = 480 , 
        resolution = 300,
        compression = "lzw",
        
        # 维恩图圈设置
        lwd = 2,
        lty = 'blank',
        fill = myCol,
        
        # 数值展示设置
        cex = .6,
        fontface = "bold",
        fontfamily = "sans",
        
        # 集合标签信息设置
        cat.cex = 0.6,
        cat.fontface = "bold",
        cat.default.pos = "outer",
        cat.pos = c(-27, 27, 135),
        cat.dist = c(0.055, 0.055, 0.085),
        cat.fontfamily = "sans",
        rotation = 1
)

如此一个漂亮的维恩图绘制好了。

参考资料:

1.https://www.r-graph-gallery.com/14-venn-diagramm.html#custom