Reputation: 1824
I figured out a way to accomplish this but it requires a lot of guesswork and all the Venn or Euler diagram packages seem to only allow you to place the total number of occurrences inside the circle.
The data:
name=c('itm1','itm2','itm3','itm4','itm5','itm6','itm7','itm8','itm9','itm0')
x=c(5,2,3,5,6,7,7,8,9,2)
y=c(6,9,9,7,6,5,2,3,2,4)
z=data.frame(name,x,y)
plot(z$x,z$y,type='n')
text(z$x,z$y,z$name)
par(new=T)
symbols(3,7,circles=2.5,add=T,bg='#34692499',inches=F)
symbols(6,6,circles=1.5,add=T,bg='#64392499',inches=F)
symbols(8,3,circles=2,add=T,bg='#24399499',inches=F)
So this is a real tedious process of giving each item an x and y coordinate and then guessing where to place the circles and what radius to give them.
Ideally I would like to use the dataset I initially had which looks like this:
cat1=c('itm2','itm3','itm0')
cat2=c('itm1','itm4','itm5','itm6')
cat3=c('itm6','itm7','itm8','itm9')
And then just assign the points into the right circle. Is there a better way of doing this?
Upvotes: 6
Views: 1374
Reputation: 8676
My sense, based on the thread discussion is to recommend using the UnSetR R package?
OK, why?
My personal feeling is that if we have more than five or seven groups the Venn diagram approach breaks down. For an overview of the various options available in this context I recommend you review:
the other useful website in my view is:
together they give good coverage of the options available.
Thus, my sense is that the core challenge here is the combinatorial explosion of the number of set intersections if the number of sets exceeds a trivial threshold. So how to address?
Well, UnSet is focused on creating a task-driven aggregate view of the data relationships, it communicates the size and properties of aggregates and intersections. For me at least this seems a better way - it is a recommendation.
That and at the very least an alternate approach - I hope it helps.
There are currently four vignettes that explain how to use the features included in the UpSetR package:
if (!require(UpSetR)) install.packages("UpSetR")
movies <- read.csv(system.file("extdata", "movies.csv", package = "UpSetR"),
header = T, sep = ";")
upset(movies, nsets = 6, number.angles = 30, point.size = 3.5, line.size = 2,
mainbar.y.label = "Genre Intersections", sets.x.label = "Movies Per Genre",
text.scale = c(1.3, 1.3, 1, 1, 2, 0.75))
upset(movies, sets = c("Action", "Adventure", "Comedy", "Drama", "Mystery",
"Thriller", "Romance", "War", "Western"), mb.ratio = c(0.55, 0.45), order.by = "freq")
Upvotes: 3
Reputation:
If you don't mind doing this manually, you can speed the process up a lot by using locator
:
points <- locator(2)
# click first at the circle centre, then somewhere on the circle edge
symbols(points$x[1], points$y[1],
circles = sqrt(sum(points$x - points$y)^2),
add = TRUE, bg = alpha('orange', .2), inches = F)
Upvotes: 0