Python matplotlib_venn.venn2() Examples
The following are 10
code examples of matplotlib_venn.venn2().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
matplotlib_venn
, or try the search function
.
Example #1
Source File: plotting.py From smallrnaseq with GNU General Public License v3.0 | 6 votes |
def venn_diagram(names,labels,ax=None,**kwargs): """Plot venn diagrams""" from matplotlib_venn import venn2,venn3 f=None if ax==None: f=plt.figure(figsize=(4,4)) ax=f.add_subplot(111) if len(names)==2: n1,n2=names v = venn2([set(n1), set(n2)], set_labels=labels, **kwargs) elif len(names)==3: n1,n2,n3=names v = venn3([set(n1), set(n2), set(n3)], set_labels=labels, **kwargs) ax.axis('off') #f.patch.set_visible(False) ax.set_axis_off() return
Example #2
Source File: VennDiagram.py From altanalyze with Apache License 2.0 | 6 votes |
def venn(data, names=None, fill="number", show_names=True, show_plot=True, outputDir=False, **kwds): """ data: a list names: names of groups in data fill = ["number"|"logic"|"both"], fill with number, logic label, or both show_names = [True|False] show_plot = [True|False] """ if data is None: raise Exception("No data!") if len(data) == 2: venn2(data, names, fill, show_names, show_plot, outputDir, **kwds) elif len(data) == 3: venn3(data, names, fill, show_names, show_plot, outputDir, **kwds) elif len(data) == 4: venn4(data, names, fill, show_names, show_plot, outputDir, **kwds) else: print len(data), 'files submitted, must be less than 4 and greater than 1...' #raise Exception("currently only 2-4 sets venn diagrams are supported") #--------------------------------------------------------------------
Example #3
Source File: compare_models.py From AmusingPythonCodes with MIT License | 5 votes |
def venn_diagram(questions, output_dir): em_model1_ids = [x for x in questions if questions[x].em[0] == 1] em_model2_ids = [x for x in questions if questions[x].em[1] == 1] model_names = questions[list(questions.keys())[0]].model_names print('\nVenn diagram') correct_model1 = em_model1_ids correct_model2 = em_model2_ids correct_model1_and_model2 = list(set(em_model1_ids).intersection(set(em_model2_ids))) correct_model1_and_not_model2 = list(set(em_model1_ids) - set(em_model2_ids)) correct_model2_and_not_model1 = list(set(em_model2_ids) - set(em_model1_ids)) print('{0} answers correctly = {1}'.format(model_names[0], len(correct_model1))) print('{0} answers correctly = {1}'.format(model_names[1], len(correct_model2))) print('Both answer correctly = {1}'.format(model_names[0], len(correct_model1_and_model2))) print('{0} correct & {1} incorrect = {2}'.format(model_names[0], model_names[1], len(correct_model1_and_not_model2))) print('{0} correct & {1} incorrect = {2}'.format(model_names[1], model_names[0], len(correct_model2_and_not_model1))) plt.clf() venn_diagram_plot = venn2( subsets=(len(correct_model1_and_not_model2), len(correct_model2_and_not_model1), len(correct_model1_and_model2)), set_labels=('{0} correct'.format(model_names[0]), '{0} correct'.format(model_names[1]), 'Both correct'), set_colors=('r', 'b'), alpha=0.3, normalize_to=1 ) plt.savefig(os.path.join(output_dir, 'venn_diagram.png')) plt.close() return correct_model1, correct_model2, correct_model1_and_model2, correct_model1_and_not_model2, correct_model2_and_not_model1
Example #4
Source File: compare_models.py From iss-rnns with Apache License 2.0 | 5 votes |
def venn_diagram(questions, output_dir): em_model1_ids = [x for x in questions if questions[x].em[0] == 1] em_model2_ids = [x for x in questions if questions[x].em[1] == 1] model_names = questions[list(questions.keys())[0]].model_names print('\nVenn diagram') correct_model1 = em_model1_ids correct_model2 = em_model2_ids correct_model1_and_model2 = list(set(em_model1_ids).intersection(set(em_model2_ids))) correct_model1_and_not_model2 = list(set(em_model1_ids) - set(em_model2_ids)) correct_model2_and_not_model1 = list(set(em_model2_ids) - set(em_model1_ids)) print('{0} answers correctly = {1}'.format(model_names[0], len(correct_model1))) print('{0} answers correctly = {1}'.format(model_names[1], len(correct_model2))) print('Both answer correctly = {1}'.format(model_names[0], len(correct_model1_and_model2))) print('{0} correct & {1} incorrect = {2}'.format(model_names[0], model_names[1], len(correct_model1_and_not_model2))) print('{0} correct & {1} incorrect = {2}'.format(model_names[1], model_names[0], len(correct_model2_and_not_model1))) plt.clf() venn_diagram_plot = venn2( subsets=(len(correct_model1_and_not_model2), len(correct_model2_and_not_model1), len(correct_model1_and_model2)), set_labels=('{0} correct'.format(model_names[0]), '{0} correct'.format(model_names[1]), 'Both correct'), set_colors=('r', 'b'), alpha=0.3, normalize_to=1 ) plt.savefig(os.path.join(output_dir, 'venn_diagram.png')) plt.close() return correct_model1, correct_model2, correct_model1_and_model2, correct_model1_and_not_model2, correct_model2_and_not_model1
Example #5
Source File: compare_models.py From convai-bot-1337 with GNU General Public License v3.0 | 5 votes |
def venn_diagram(questions, output_dir): em_model1_ids = [x for x in questions if questions[x].em[0] == 1] em_model2_ids = [x for x in questions if questions[x].em[1] == 1] model_names = questions[list(questions.keys())[0]].model_names print('\nVenn diagram') correct_model1 = em_model1_ids correct_model2 = em_model2_ids correct_model1_and_model2 = list(set(em_model1_ids).intersection(set(em_model2_ids))) correct_model1_and_not_model2 = list(set(em_model1_ids) - set(em_model2_ids)) correct_model2_and_not_model1 = list(set(em_model2_ids) - set(em_model1_ids)) print('{0} answers correctly = {1}'.format(model_names[0], len(correct_model1))) print('{0} answers correctly = {1}'.format(model_names[1], len(correct_model2))) print('Both answer correctly = {1}'.format(model_names[0], len(correct_model1_and_model2))) print('{0} correct & {1} incorrect = {2}'.format(model_names[0], model_names[1], len(correct_model1_and_not_model2))) print('{0} correct & {1} incorrect = {2}'.format(model_names[1], model_names[0], len(correct_model2_and_not_model1))) plt.clf() venn_diagram_plot = venn2( subsets=(len(correct_model1_and_not_model2), len(correct_model2_and_not_model1), len(correct_model1_and_model2)), set_labels=('{0} correct'.format(model_names[0]), '{0} correct'.format(model_names[1]), 'Both correct'), set_colors=('r', 'b'), alpha=0.3, normalize_to=1 ) plt.savefig(os.path.join(output_dir, 'venn_diagram.png')) plt.close() return correct_model1, correct_model2, correct_model1_and_model2, correct_model1_and_not_model2, correct_model2_and_not_model1
Example #6
Source File: compare_models.py From adversarial-squad with MIT License | 5 votes |
def venn_diagram(questions, output_dir): em_model1_ids = [x for x in questions if questions[x].em[0] == 1] em_model2_ids = [x for x in questions if questions[x].em[1] == 1] model_names = questions[list(questions.keys())[0]].model_names print('\nVenn diagram') correct_model1 = em_model1_ids correct_model2 = em_model2_ids correct_model1_and_model2 = list(set(em_model1_ids).intersection(set(em_model2_ids))) correct_model1_and_not_model2 = list(set(em_model1_ids) - set(em_model2_ids)) correct_model2_and_not_model1 = list(set(em_model2_ids) - set(em_model1_ids)) print('{0} answers correctly = {1}'.format(model_names[0], len(correct_model1))) print('{0} answers correctly = {1}'.format(model_names[1], len(correct_model2))) print('Both answer correctly = {1}'.format(model_names[0], len(correct_model1_and_model2))) print('{0} correct & {1} incorrect = {2}'.format(model_names[0], model_names[1], len(correct_model1_and_not_model2))) print('{0} correct & {1} incorrect = {2}'.format(model_names[1], model_names[0], len(correct_model2_and_not_model1))) plt.clf() venn_diagram_plot = venn2( subsets=(len(correct_model1_and_not_model2), len(correct_model2_and_not_model1), len(correct_model1_and_model2)), set_labels=('{0} correct'.format(model_names[0]), '{0} correct'.format(model_names[1]), 'Both correct'), set_colors=('r', 'b'), alpha=0.3, normalize_to=1 ) plt.savefig(os.path.join(output_dir, 'venn_diagram.png')) plt.close() return correct_model1, correct_model2, correct_model1_and_model2, correct_model1_and_not_model2, correct_model2_and_not_model1
Example #7
Source File: compare_models.py From bi-att-flow with Apache License 2.0 | 5 votes |
def venn_diagram(questions, output_dir): em_model1_ids = [x for x in questions if questions[x].em[0] == 1] em_model2_ids = [x for x in questions if questions[x].em[1] == 1] model_names = questions[list(questions.keys())[0]].model_names print('\nVenn diagram') correct_model1 = em_model1_ids correct_model2 = em_model2_ids correct_model1_and_model2 = list(set(em_model1_ids).intersection(set(em_model2_ids))) correct_model1_and_not_model2 = list(set(em_model1_ids) - set(em_model2_ids)) correct_model2_and_not_model1 = list(set(em_model2_ids) - set(em_model1_ids)) print('{0} answers correctly = {1}'.format(model_names[0], len(correct_model1))) print('{0} answers correctly = {1}'.format(model_names[1], len(correct_model2))) print('Both answer correctly = {1}'.format(model_names[0], len(correct_model1_and_model2))) print('{0} correct & {1} incorrect = {2}'.format(model_names[0], model_names[1], len(correct_model1_and_not_model2))) print('{0} correct & {1} incorrect = {2}'.format(model_names[1], model_names[0], len(correct_model2_and_not_model1))) plt.clf() venn_diagram_plot = venn2( subsets=(len(correct_model1_and_not_model2), len(correct_model2_and_not_model1), len(correct_model1_and_model2)), set_labels=('{0} correct'.format(model_names[0]), '{0} correct'.format(model_names[1]), 'Both correct'), set_colors=('r', 'b'), alpha=0.3, normalize_to=1 ) plt.savefig(os.path.join(output_dir, 'venn_diagram.png')) plt.close() return correct_model1, correct_model2, correct_model1_and_model2, correct_model1_and_not_model2, correct_model2_and_not_model1
Example #8
Source File: VennDiagram.py From altanalyze with Apache License 2.0 | 5 votes |
def test(): """ a test function to show basic usage of venn()""" # venn3() venn([range(10), range(5,15), range(3,8)], ["aaaa", "bbbb", "cccc"], fill="both", show_names=False) # venn2() venn([range(10), range(5,15)]) venn([range(10), range(5,15)], ["aaaa", "bbbb"], fill="logic", show_names=False) # venn4() venn([range(10), range(5,15), range(3,8), range(4,9)], ["aaaa", "bbbb", "cccc", "dddd"], figsize=(12,12)) ######### Added for AltAnalyze #########
Example #9
Source File: venn_survivor_calls.py From nano-snakemake with MIT License | 5 votes |
def check_vcf(vcf): """Check if vcf is suited for this script returns - appropriate venn function - appropriate empty list of lists for identifiers """ if len(vcf.samples) == 2: return venn2, [[] for i in range(len(vcf.samples))] elif len(vcf.samples) == 3: return venn3, [[] for i in range(len(vcf.samples))] else: sys.exit("Fatal: Script only written for vcf files containing 2 or 3 samples")
Example #10
Source File: VennDiagram.py From altanalyze with Apache License 2.0 | 4 votes |
def SimpleMatplotVenn(names,data,outputDir=False,display=True): """ Uses http://pypi.python.org/pypi/matplotlib-venn (code combined into one module) to export simple or complex, overlapp weighted venn diagrams as an alternative to the default methods in this module """ import numpy as np pylab.figure(figsize=(11,7),facecolor='w') vd = get_labels(data, fill="number") set_labels=[] for i in names: set_labels.append(string.replace(i,'.txt','')) if len(set_labels)==2: from matplotlib_venn import venn2, venn2_circles set_colors = ('r', 'g') subsets = (vd['10'], vd['01'], vd['11']) v = venn2(subsets=subsets, set_labels = set_labels, set_colors=set_colors) c = venn2_circles(subsets=subsets, alpha=0.5, linewidth=1.5, linestyle='dashed') if len(set_labels)==3: from matplotlib_venn import venn3, venn3_circles set_colors = ('r', 'g', 'b') subsets = (vd['100'], vd['010'], vd['110'], vd['001'], vd['101'], vd['011'], vd['111']) v = venn3(subsets=subsets, set_labels = set_labels,set_colors=set_colors) c = venn3_circles(subsets=subsets, alpha=0.5, linewidth=1.5, linestyle='dashed') pylab.title("Overlap Weighted Venn Diagram",fontsize=24) try: if outputDir!=False: filename = outputDir+'/%s.pdf' % venn_export_weighted pylab.savefig(filename) filename = outputDir+'/%s.png' % venn_export_weighted pylab.savefig(filename, dpi=100) #,dpi=200 except Exception: print 'Image file not saved...' if display: pylab.show() try: import gc fig.clf() pylab.close() gc.collect() except Exception: pass ######### End Added for AltAnalyze #########