Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to make a Venn diagram with all the points inside?

Tags:

r

venn-diagram

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)

Plotting the points and labeling them:

plot(z$x,z$y,type='n')
text(z$x,z$y,z$name)

enter image description here

Manually placing the circles over the points:

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)

enter image description here

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?

like image 780
thequerist Avatar asked Jun 07 '17 01:06

thequerist


People also ask

Can you have a 4 way Venn diagram?

... it is impossible to draw a Venn diagram with circles that will represent all the possible intersections of four (or more) sets.

What is the figure that enclosed all the sets inside a Venn diagram?

The relation between the sets of natural numbers, whole numbers and integers can be shown by the Venn diagram, where the set of integers is the universal set. See the figure below. The universal set (U) is usually represented by a closed rectangle, consisting of all the sets.

What is a stacked Venn diagram?

3. The third type is Stacked Venn. This is used to show overlapping relationships and is considered a good choice for emphasizing growth or gradation of an organization or business.


1 Answers

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:

  • Information Engineering Group Web Page
    • Resources on Set Visualization

the other useful website in my view is:

  • Venn Diagrams on R Studio

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?


Proposed Solution UnSet

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.

UnSet Reference Materials:

  • UnSet Overview http://caleydo.org/tools/upset/
  • Shiny Application: https://gehlenborglab.shinyapps.io/upsetr/
  • R Package Source Code: https://github.com/hms-dbmi/UpSetR
  • Further reading pertaining to alternnate options: http://www.cvast.tuwien.ac.at/SetViz

UnSetR Vignettes

There are currently four vignettes that explain how to use the features included in the UpSetR package:

  • Basic Usage
  • Queries
  • Attribute Plots
  • Set Metadata

Unset Movie DataSet Example 1

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))

enter image description here

Unset Movie DataSet Example 2

upset(movies, sets = c("Action", "Adventure", "Comedy", "Drama", "Mystery", 
                       "Thriller", "Romance", "War", "Western"), mb.ratio = c(0.55, 0.45), order.by = "freq")

enter image description here

like image 167
Technophobe01 Avatar answered Oct 05 '22 09:10

Technophobe01