本文整理汇总了Python中matplotlib_venn.venn2方法的典型用法代码示例。如果您正苦于以下问题:Python matplotlib_venn.venn2方法的具体用法?Python matplotlib_venn.venn2怎么用?Python matplotlib_venn.venn2使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlib_venn
的用法示例。
在下文中一共展示了matplotlib_venn.venn2方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: venn_diagram
# 需要导入模块: import matplotlib_venn [as 别名]
# 或者: from matplotlib_venn import venn2 [as 别名]
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
示例2: venn
# 需要导入模块: import matplotlib_venn [as 别名]
# 或者: from matplotlib_venn import venn2 [as 别名]
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")
#--------------------------------------------------------------------
示例3: venn_diagram
# 需要导入模块: import matplotlib_venn [as 别名]
# 或者: from matplotlib_venn import venn2 [as 别名]
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
示例4: test
# 需要导入模块: import matplotlib_venn [as 别名]
# 或者: from matplotlib_venn import venn2 [as 别名]
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 #########
示例5: check_vcf
# 需要导入模块: import matplotlib_venn [as 别名]
# 或者: from matplotlib_venn import venn2 [as 别名]
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")
示例6: SimpleMatplotVenn
# 需要导入模块: import matplotlib_venn [as 别名]
# 或者: from matplotlib_venn import venn2 [as 别名]
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 #########