Reputation: 17
I created a Venn Diagram using the eulerr package but it doesn't let me customize it and the outlines of the inner circles seem to touch the sample space circle. I looked through the VennDiagram package manual but had no luck. Is there a way to create a Venn Diagram using either ggplot2 or any other R packages.
I am looking to do what this user was trying to do with the data I have. 3 sets that fall into the complete sample space. How to draw a venn diagram subset by a main vector in R
This is what was created using the eulerr package:
This is the data that I have. Circles B, C, and D should be inside circle A which has a total of 141. The 35 in variable a is the space between the 3 venn diagram and the circle (white space).
b = c(50,0,9,2,1,0,0,0)
c = c(50,21,0,2,0,3,0,0)
d = c(50,21,9,2,0,3,20,0)
a = c(50, 21, 9, 2,1,3,20,35)
totes = cbind(b, c, d, a)
I don't know how to go about this and make a presentable diagram that I can customize.
When I used the eulerr package, I manually entered the data in the command.
Upvotes: 0
Views: 2175
Reputation: 2628
You may consider my nVennR
package. With your data,
>library(nVennR)
> myV <- plotVenn(list(b = c(50,9,2,1),
+ c = c(50,21,2,3),
+ d = c(50,21,9,2,3,20),
+ a = c(50, 21, 9, 2,1,3,20,35)))
> showSVG(myV, opacity = 0.2, borderWidth = 1)
And the result:
You can also list the elements in each region:
> listVennRegions(myV)
$`0, 0, 0, 1 (a)`
[1] 35
$`0, 0, 1, 1 (d, a)`
[1] 20
$`0, 1, 1, 1 (c, d, a)`
[1] 21 3
$`1, 0, 0, 1 (b, a)`
[1] 1
$`1, 0, 1, 1 (b, d, a)`
[1] 9
$`1, 1, 1, 1 (b, c, d, a)`
[1] 50 2
Please, notice that I removed the zeroes in your list. The package takes those zeroes as elements, which were not present in list a. If you are interested, you can find a vignette and a web interface for the algorithm.
Upvotes: 1