Error in [R] VennDiagram: "Impossible...produces negative area"

2.9k views Asked by At

I am having trouble creating a plot using VennDiagram. Below is my code and error:

venn.plot <- draw.quad.venn(area1 = 412, area2 = 471, area3 = 137, area4 = 1507, n12 = 11, n13 = 1, n14 = 132, n23 = 0, n24 = 183, n34 = 24, n123 = 1, n124 = 143, n134 = 18, n234 = 14, n1234 = 64, category = c("Set1", "Set2", "Set3", "Set4"), fill = c("orange", "red", "green", "blue"), lty = "dashed", cex = 2, cat.cex = 2, cat.col = c("orange", "red", "green", "blue"));

Error in draw.quad.venn(area1 = 412, area2 = 471, area3 = 137, area4 = 1507,  : 
Impossible: a5  <- n134 - a6 produces negative area

I checked my math, but might have missed something? Any thoughts?

1

There are 1 answers

4
Carl Witthoft On

The problem is IMHO the lack of documentation. Try running the example code for draw.triple.venn . You'll see that the values in the pairwise overlap regions consist of the argument values minus the 3-way argument value. That is,

venn.plot <- draw.triple.venn(
    area1 = 65,
    area2 = 75,
    area3 = 85,
    n12 = 35,
    n23 = 15,
    n13 = 25,
    n123 = 5)

Produces a plot with '30' '20', '10' in the 2-way regions. You'll have to do the same sort of subtraction to your input values, I suspect.