调用包 VennDiagram
library(VennDiagram)
两个集的韦恩图
venn.plot <- draw.pairwise.venn(
area1 = 100, #第一个集大小
area2 = 70, #第二个集大小
cross.area = 68, #两个集的交集大小
category = c("First", "Second"), #两个集命名
fill = c("blue", "yellow"), #集对应的圈填充颜色
lty = "blank", #圆周的线条类型
cex = 1, #韦恩图各部分面积标签注释字体大小
cat.cex = 3, #集名字体大小
cat.pos = c(180, 0), #集标签围绕圆的相对位置,0-360°,默认0°在12点钟方向
cat.dist = c(0.03,0.06), #集标签相对于圆位置远近
cat.just = list(c(0, 0), c(0, 0)),
ext.pos = 0, #圈外面积标签位置
ext.dist = -0.05,
ext.length = 0.85, #圈外面积标签连接线长度
ext.line.lwd = 2,
ext.line.lty = "dashed", #圈外面积标签连接线类型
alpha=0.3,
euler.d=T #没有交集,是否分开
);
tiff(filename = "Pairwise_Venn_diagram.tiff");
grid.draw(venn.plot);
dev.off()
文章图片
Pairwise_Venn_diagram 四个集的韦恩图
venn.plot <- draw.quad.venn(
area1 = 72,
area2 = 86,
area3 = 50,
area4 = 52,
n12 = 44,
n13 = 27,
n14 = 32,
n23 = 38,
n24 = 32,
n34 = 20,
n123 = 18,
n124 = 17,
n134 = 11,
n234 = 13,
n1234 = 6,
category = c("First", "Second", "Third", "Fourth"),
fill = c("orange", "red", "green", "blue"),
lty = "dashed",
cex = 2,
cat.cex = 2,
cat.col = c("orange", "red", "green", "blue")
);
tiff(filename = "Quad_Venn_diagram.tiff");
grid.draw(venn.plot);
dev.off();
文章图片
Quad_Venn_diagram venn.diagram()画韦恩图
a<-sample(1:50,26,replace = F)
b<-sample(1:50,26,replace = F)
c<-sample(1:50,26,replace = F)
venn.plot <- venn.diagram(
list(a = a,
b = b,
c=c
),filename="test.tiff",
main="Main title",
sub = "Subtitle",
col="black",
fill=c("blue","red","yellow"),
cat.pos = c(0, 0, 180)
)
当前路径下生成图片test.tiff
文章图片
venn.diagram 【R|R 画韦恩图】