2017-02-16 92 views
2

我想繪製兩組維納圖,其中一組完全落入另一組。我可以得出有R包Venndiagram圖這樣如何在繪製維恩圖時調整圓的位置

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 one here。我添加了一個不重疊的元素。

我在Venndiagram包中找不到參數,允許我調整圓的位置。

+0

這沒有多大意義,因爲一個包含了其他。以下是您可以查看的幾個示例:https://rstudio-pubs-static.s3.amazonaws.com/13301_6641d73cfac741a59c0a851feb99e98b.html和http://rstudio-pubs-static.s3.amazonaws.com/6401_7582b217798044d3ae87ebbdc47b7562.html – lizzie

+0

@莉齊。感謝您的評論,是的,我檢查了您建議的網頁,但仍無法找到調整圈子位置的任何論據。我可以通過添加一個非重疊的元素,比如我在帖子中添加的示例,但是... – Jun

回答

1

您可以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

+0

其實在文本中有一個錯字,它應該是273而不是272. –

+1

是的,它的工作原理! TKS!解決方案比我預想的複雜得多...... PS:有一個小凹凸圖(0:40,0:40,type =「n」,xlab =「」,ylab =「」,main =「維恩圖「,xaxt ='n',yaxt ='n') 在plot.new()中的錯誤:圖邊距過大 – Jun

+1

但可以很容易地通過解決方案建議[這裏] http://stackoverflow.com/questions/ 「12766166/error-in-plot-new-figure-margins-too-large-in-r – Jun