sop_se - 6 months ago 38

R Question

I am trying to make something like this:

My code is still in this stage:

Unfortunately I can't set the coordinates of circles' centres with the VennDiagram package. Does anyone know a trick for achieving that? Or another package that gets closer to the graphic I'm looking for?

`library(VennDiagram)`

venn.plot <- draw.triple.venn(area1=A, area2=B, area3=C,

n12 =A, n23 = B, n13 = A, n123 = A,

fill = c("yellow1", "yellow3", "yellow4"),

euler = TRUE,

c("First", "Second", "Third") )

Answer

For your specific case (nested subsets), you could just manually draw three circles using grid. Assuming set A contains set B contains set C:

```
set_sizes <- c(A = 25, B = 16, C = 9)
set_radii <- 0.5 * c(
A = 1,
B = sqrt(set_sizes["B"] / set_sizes["A"]),
C = sqrt(set_sizes["C"] / set_sizes["A"])
)
grid.newpage()
grid.circle(
y = set_radii,
r = set_radii,
gp = gpar(fill = c("red", "green", "blue"))
)
```