def plot_ven(labels, names): if len(names) == 2: return pv.venn2(labels, names=names) elif len(names) == 3: return pv.venn3(labels, names=names) elif len(names) == 4: return pv.venn4(labels, names=names) elif len(names) == 5: return pv.venn5(labels, names=names) elif len(names) == 6: return pv.venn6(labels, names=names) else: raise Error("Unsupported Venn")
# coding: utf-8 # ipython notebook requires this # %matplotlib inline # python console requires this import matplotlib matplotlib.use('Agg') import matplotlib.pyplot as plt from pyvenn import venn labels = venn.get_labels([range(10), range(5, 15)], fill=['number', 'logic']) fig, ax = venn.venn2(labels, names=['list 1', 'list 2']) fig.savefig('venn2.png', bbox_inches='tight') plt.close() labels = venn.get_labels( [range(10), range(5, 15), range(3, 8)], fill=['number', 'logic']) fig, ax = venn.venn3(labels, names=['list 1', 'list 2', 'list 3']) fig.savefig('venn3.png', bbox_inches='tight') plt.close() labels = venn.get_labels( [range(10), range(5, 15), range(3, 8), range(8, 17)], fill=['number', 'logic']) fig, ax = venn.venn4(labels, names=['list 1', 'list 2', 'list 3', 'list 4']) fig.savefig('venn4.png', bbox_inches='tight') plt.close()