2

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.

lmo
  • 37,904
  • 9
  • 56
  • 69
Jun
  • 309
  • 1
  • 5
  • 16
  • It does not make much sense since one contains the other. Here are few examples you could look at: https://rstudio-pubs-static.s3.amazonaws.com/13301_6641d73cfac741a59c0a851feb99e98b.html and http://rstudio-pubs-static.s3.amazonaws.com/6401_7582b217798044d3ae87ebbdc47b7562.html – lizzie Feb 16 '17 at 05:11
  • @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 Feb 16 '17 at 06:00

1 Answers1

1

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

d.b
  • 32,245
  • 6
  • 36
  • 77
Sandipan Dey
  • 21,482
  • 2
  • 51
  • 63
  • Actually there is a typo in the text, it should be 273 instead of 272. – Sandipan Dey Feb 17 '17 at 13:48
  • 1
    yes, It works! TKS! The solution is much more complicated than I expected... PS: there is one little bump plot(0:40,0:40,type="n",xlab="",ylab="",main="Venn Diagram", xaxt='n', yaxt='n') Error in plot.new() : figure margins too large – Jun Feb 17 '17 at 13:51
  • 1
    but can be easily solved by the solution suggested [here]http://stackoverflow.com/questions/12766166/error-in-plot-new-figure-margins-too-large-in-r – Jun Feb 17 '17 at 13:53
  • 1
    "Actually there is a typo in the text, it should be 273 instead of 272." that is all right, this is just an example, TKS very much! – Jun Feb 17 '17 at 13:55
  • @Sandipian Dey, I would very much like to up vote your answer, but could not since my reputation is lower than 15, which is minimal for up voting. By "update the answer", but do you mean by that? You really solve my issue, so very happy to do any thing if that helps you. – Jun Feb 17 '17 at 14:15