2
votes

I wanted to plot the venn diagram with two sets in which one set falls completely within another. I could draw a diagram with R package Venndiagram like this

enter image description here

library(VennDiagram)
grid.newpage();
venn.plot <- draw.pairwise.venn(area1 =467 ,area2 =273 ,cross.area = 273,
category = c("Set1", "Set2"),fill = c("darkorange", "dodgerblue1"),
lty = rep("solid", 2),lwd = c(2,2),col = c("black","black"),cex = 2,cat.cex = 2,cat.pos = c(310, 135),
cat.dist = 0.09,cat.just = list(c(-1, -1), c(1, 1)),
ext.pos = 30,ext.dist = -0.05,
ext.length = 0.85,ext.line.lwd = 2,ext.line.lty = "dashed");
grid.draw(venn.plot);

This may sound like esoteric tricks, but how to adjust the position of the circles, say, instead of two concentric circles, let the inner circle touch the the outer one?

Something like this one here. I added one non overlapping element.

I could not find an argument in the Venndiagram package allowing me to adjust the position of the circles.

1
It does not make much sense since one contains the other. Here are few examples you could look at: rstudio-pubs-static.s3.amazonaws.com/… and rstudio-pubs-static.s3.amazonaws.com/…lizzie
@lizzie. Thank you for your comment, yes, I checked the web you suggested, but still could not find any argument to adjust the position of the circles. I could cheat by add a non overlapping element like the example I added in the post, but...Jun

1 Answers

1
votes

You can try this with plotrix:

library(plotrix)
area1 = 467 
area2 = 273
r1 = round(sqrt(area1/pi))
r2 = round(sqrt(area2/pi))
xc = 8
yc = 8
plot(0:40,0:40,type="n",xlab="",ylab="",main="Venn Diagram", xaxt='n', yaxt='n')
draw.circle(xc+r1,yc+r1,r1,border="black", col="orange",lty=1,lwd=1)
draw.circle(xc+2*r1-r2,yc+r1,r2,border="black", col="steelblue",lty=1,lwd=1)
text(xc+2*r1-r2,yc+r1, '272', cex=3)  
text(xc+(r1-r2)/2+1,yc+r1, '195', cex=3) 
text(xc+r1,yc+2*r1+7, 'Set1', cex=3) 
text(xc+r1+r2,1, 'Set2', cex=3) 

enter image description here