# [Baypiggies] Fwd: Venn diagram for five events

Mark Voorhies mvoorhie at yahoo.com
Fri May 6 18:39:45 CEST 2011

```Your four event diagram misses 2 of the 15 possible intersections
(yellow + green and red + blue).

This becomes an increasingly difficult topology problem as you add
circles (you need to deal with (2^n)-1 intersections each time).  A
related problem is that as soon as you have more than two circles,
you can not in general make the intersection areas proportional to
the size of the corresponding set intersection.

An alternate graphic that is useful at high n is a clustered heatmap:

1) Generate a matrix where each column, j, is one of your circles and
each row, i, an element, with cell ij = 1 if i is a member of j, 0 otherwise.

2) Apply a clustering algorithm to group the rows by related intersections.

http://bonsai.hgc.jp/~mdehoon/software/cluster/

JavaTreeView is a nice visualization tool based on PyCluster's output format:
http://jtreeview.sourceforge.net/

--Mark

On Friday, May 06, 2011 04:58:05 am Vikram K wrote:
> This works for four events and their intersections but how do i add the
> fifth event along with all intersections?
>
> from matplotlib import pyplot as plt
> from matplotlib.patches import Circle
>
> f = plt.figure()
> ax = f.gca()
> c1 = Circle((-1,0),rad, alpha=.2, fc ='red')
> c2 = Circle((1,0),rad, alpha=.2, fc ='blue')
> c3 = Circle((0,1),rad, alpha=.2, fc ='green')
> c4 = Circle((0,-1),rad, alpha=.2, fc ='yellow')
> ax.set_xlim(-3,3)
> ax.set_ylim(-3,3)
> plt.show()
>
> ---------- Forwarded message ----------
> From: Vikram K <kpguy1975 at gmail.com>
> Date: Fri, May 6, 2011 at 7:48 AM
> Subject: Venn diagram for five events
> To: baypiggies at python.org
>
>
> I sent the following query to the matplotlib list a while back. I would
> appreciate it if someone here can answer my question. Also, is there an
> alternative to matplotlib for this kind of a problem?
> -------
>
> I wish to draw a Venn diagram depicting five events and their intersections.
> I came across some code for three events--could someone please direct me
> about how i could modify it for five events.
>
> from matplotlib import pyplot as plt
> from matplotlib.patches import Circle
>
> f = plt.figure()
> ax = f.gca()
> c1 = Circle((-1,0),rad, alpha=.2, fc ='red')
> c2 = Circle((1,0),rad, alpha=.2, fc ='blue')
> c3 = Circle((0,1),rad, alpha=.2, fc ='green')