Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

scaling triple Venn diagram in R with VennDiagram package

Tags:

r

venn-diagram

Does anyone know how to get the R package VennDiagram to scale the circles of a Venn diagram containing 3 intersecting sets according to set size?

I can achieve such scaling with the venneular package, but I find this a bit limited in terms of other graphical options compared to VennDiagram.

The VennDiagram package documentation suggests setting the argument 'scaled' to TRUE ought to do the trick, but I find this produces 3 circles of equal size.

The package documentation does cryptically suggest that the scaled argument may only work for certain diagrams:

?draw.triple.venn

reveals:

scaled: "Boolean indicating whether to scale circle sizes in certain Euler diagrams according to set sizes or not"

and

?venn.diagram

#Argument Venn Sizes    Class    Description
#scaled    2, 3         logical  Enable scaling for two-set and certain three-set Euler diagrams.

A toy example of my code:

require(VennDiagram)

venn.plot <- draw.triple.venn(
    area1 = 70,
    area2 = 250,
    area3 = 500,
    n12 = 30,
    n23 = 60,
    n13 = 10,
    n123 = 5,
    category = c("C1", "C2", "C3"),
    fill = c("blue", "red", "green"),
    scaled=TRUE)

tiff(filename = "test.tiff", compression = "none",type = "quartz",antialias = "none")
grid.draw(venn.plot)
dev.off()

Similarly this code using the 'venn.diagram' function doesn't produce the required scaling:

venn.diagram(x=list(A=c(1:15,16:20), B=c(6:15,21:30,100:150), C=c(11:30,200:300)),
         filename="test.tiff",
         fill = c("blue", "yellow", "red"), scaled=TRUE)

Thanks v.much

Jim

like image 626
user1563570 Avatar asked Jul 30 '12 18:07

user1563570


People also ask

How do I install Venn diagram in R?

Install “VennDiagram” Package (One-time setup)At the project list view, you can click “R Packages” link to open the 'Manage R Package” dialog. Click the “Install New Packages” tab, type in “VennDiagram” in the input field, and click “Install”. You will see a success message if the installation goes well.

Can you use a Venn diagram to compare three things?

A Venn diagram is a classic way of getting students to compare and contrast the similarities and differences between two or three key events, concepts or people.

Is used to represent logical relations between finite collection of sets?

A Venn diagram is a diagram that shows the relationship between and among a finite collection of sets. If we have two or more sets, we can use a Venn diagram to show the logical relationship among these sets as well as the cardinality of those sets. In particular, Venn Diagrams are used to demonstrate De Morgan's Laws.


1 Answers

My solution:

overrideTriple=T
draw.triple.venn(9, 20, 30, 2, 10, 3, 2, category =
               rep("", 3), rotation = 1, reverse = FALSE, euler.d = F, scaled = F)
like image 131
atongsa Avatar answered Sep 21 '22 20:09

atongsa