Venn Test


In [1]:
%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt

In [2]:
import matplotlib_venn

In [3]:
matplotlib_venn?

In [7]:
from matplotlib_venn import venn3, venn3_circles
plt.figure(figsize=(4,4))
v = venn3(subsets=(1, 1, 1, 1, 1, 1, 1), set_labels = ('A', 'B', 'C'))
v.get_patch_by_id('100').set_alpha(1.0)
v.get_patch_by_id('100').set_color('white')
v.get_label_by_id('100').set_text('Unknown')
v.get_label_by_id('A').set_text('Set "A"')
c = venn3_circles(subsets=(1, 1, 1, 1, 1, 1, 1), linestyle='dashed')
c[0].set_lw(1.0)
c[0].set_ls('dotted')
plt.title("Sample Venn diagram")
plt.annotate('Unknown set', xy=v.get_label_by_id('100').get_position() - np.array([0, 0.05]), xytext=(-70,-70),
            ha='center', textcoords='offset points', bbox=dict(boxstyle='round,pad=0.5', fc='gray', alpha=0.1),
            arrowprops=dict(arrowstyle='->', connectionstyle='arc3,rad=0.5',color='gray'))


Out[7]:
<matplotlib.text.Annotation at 0x105ab6d10>

In [8]:
from matplotlib_venn import venn2, venn2_circles

In [9]:
venn2?

In [28]:
#>>> v = venn2(subsets={'10': 315-289, '01': 316-289, '11': 289}, set_labels = ('A', 'B'))
>>> v = venn2(subsets={'10': 1, '01': 1, '11': 1}, set_labels = ('A', 'B'))
#>>> c = venn2_circles(subsets=(12, 12, 1), linestyle='dashed')
>>> v.get_patch_by_id('10').set_alpha(1.0)
#>>> v.get_patch_by_id('10').set_color('red')
>>> v.get_label_by_id('10').set_text(str(315-289))
>>> v.get_label_by_id('01').set_text(str(316-289))
>>> v.get_label_by_id('11').set_text(str(289))
#>>> v.get_label_by_id('A').set_text('Set A')



In [11]:
>>> v = venn2(subsets=[set([1,2]), set([2,3,4,5])], set_labels = ('A', 'B'))
>>> c = venn2_circles(subsets=[set([1,2]), set([2,3,4,5])], linestyle='dashed')
>>> print("%0.2f" % (v.get_circle_radius(1)/v.get_circle_radius(0)))


1.41

subsets


In [3]:
%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt

In [11]:
from matplotlib_subsets import treesets_rectangles

In [12]:
help(treesets_rectangles)


Help on function treesets_rectangles in module matplotlib_subsets:

treesets_rectangles(tree)


In [16]:
tree = ((120, '120', None), 
        [
        ((30, 'A30', None), []),
        ((30, 'B30', None), []),
        ((20, 'C20', None), [])
        ])

treesets_rectangles(tree);


node (120, '120', None)
   has 3 children:
     0: ((30, 'A30', None), [])
     1: ((30, 'B30', None), [])
     2: ((20, 'C20', None), [])
yratio (120, '120', None): 0.666666666667
deltax, deltay: 1.0 1.0
arearatio of child: 0.25
splitting in y: starting box ((0.0, 0.0), (1.0, 1.0))
splitting in y: child box ((0.0, 0.0), (1.0, 0.23556624327025935))
splitting in y: remaining box ((0.0, 0.26443375672974062), (1.0, 1.0))
node (30, 'A30', None)
   has 0 children:
picked attrs: {'alpha': 0.7, 'fc': 'None', 'ec': 'black'}
plotting A30 at ((0.0, 0.0), (1.0, 0.23556624327025935))
arearatio of child: 0.25
splitting in y: starting box ((0.0, 0.26443375672974062), (1.0, 1.0))
splitting in y: child box ((0.0, 0.26443375672974062), (1.0, 0.49999999999999994))
splitting in y: remaining box ((0.0, 0.52886751345948124), (1.0, 1.0))
node (30, 'B30', None)
   has 0 children:
picked attrs: {'alpha': 0.7, 'fc': 'None', 'ec': 'blue'}
plotting B30 at ((0.0, 0.26443375672974062), (1.0, 0.49999999999999994))
arearatio of child: 0.166666666667
splitting in y: starting box ((0.0, 0.52886751345948124), (1.0, 1.0))
splitting in y: child box ((0.0, 0.52886751345948124), (1.0, 0.6811004233964072))
splitting in y: remaining box ((0.0, 0.70996793685588855), (1.0, 1.0))
node (20, 'C20', None)
   has 0 children:
picked attrs: {'alpha': 0.7, 'fc': 'None', 'ec': 'red'}
plotting C20 at ((0.0, 0.52886751345948124), (1.0, 0.6811004233964072))
picked attrs: {'alpha': 0.7, 'fc': 'None', 'ec': 'green'}
plotting 120 at ((0.0, 0.0), (1.0, 1.0))

In [ ]: