当前位置: 首页>>代码示例>>Python>>正文


Python matplotlib_venn.venn3方法代码示例

本文整理汇总了Python中matplotlib_venn.venn3方法的典型用法代码示例。如果您正苦于以下问题:Python matplotlib_venn.venn3方法的具体用法?Python matplotlib_venn.venn3怎么用?Python matplotlib_venn.venn3使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在matplotlib_venn的用法示例。


在下文中一共展示了matplotlib_venn.venn3方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: venn_diagram

# 需要导入模块: import matplotlib_venn [as 别名]
# 或者: from matplotlib_venn import venn3 [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 
开发者ID:dmnfarrell,项目名称:smallrnaseq,代码行数:20,代码来源:plotting.py

示例2: venn

# 需要导入模块: import matplotlib_venn [as 别名]
# 或者: from matplotlib_venn import venn3 [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")

#-------------------------------------------------------------------- 
开发者ID:nsalomonis,项目名称:altanalyze,代码行数:24,代码来源:VennDiagram.py

示例3: test

# 需要导入模块: import matplotlib_venn [as 别名]
# 或者: from matplotlib_venn import venn3 [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 ######### 
开发者ID:nsalomonis,项目名称:altanalyze,代码行数:14,代码来源:VennDiagram.py

示例4: make_venn3_region_patch

# 需要导入模块: import matplotlib_venn [as 别名]
# 或者: from matplotlib_venn import venn3 [as 别名]
def make_venn3_region_patch(region):
    '''
    Given a venn3 region (as returned from compute_venn3_regions) produces a Patch object,
    depicting the region as a curve.

    >>> centers, radii = solve_venn3_circles((1, 1, 1, 1, 1, 1, 1))
    >>> regions = compute_venn3_regions(centers, radii)
    >>> patches = [make_venn3_region_patch(r) for r in regions]
    '''
    if region is None or len(region[0]) == 0:
        return None
    if region[0] == "CIRCLE":
        return Circle(region[1][0], region[1][1])
    pts, arcs, label_pos = region
    path = [pts[0]]
    for i in range(len(pts)):
        j = (i + 1) % len(pts)
        (center, radius, direction) = arcs[i]
        fromangle = vector_angle_in_degrees(pts[i] - center)
        toangle = vector_angle_in_degrees(pts[j] - center)
        if direction:
            vertices = Path.arc(fromangle, toangle).vertices
        else:
            vertices = Path.arc(toangle, fromangle).vertices
            vertices = vertices[np.arange(len(vertices) - 1, -1, -1)]
        vertices = vertices * radius + center
        path = path + list(vertices[1:])
    codes = [1] + [4] * (len(path) - 1)
    return PathPatch(Path(path, codes)) 
开发者ID:nsalomonis,项目名称:altanalyze,代码行数:31,代码来源:matplotlib_venn.py

示例5: venn3_circles

# 需要导入模块: import matplotlib_venn [as 别名]
# 或者: from matplotlib_venn import venn3 [as 别名]
def venn3_circles(subsets, normalize_to=1.0, alpha=1.0, color='black', linestyle='solid', linewidth=2.0, **kwargs):
    '''
    Plots only the three circles for the corresponding Venn diagram.
    Useful for debugging or enhancing the basic venn diagram.
    parameters sets and normalize_to are the same as in venn3()
    kwargs are passed as-is to matplotlib.patches.Circle.
    returns a list of three Circle patches.

    >>> plot = venn3_circles({'001': 10, '100': 20, '010': 21, '110': 13, '011': 14})
    '''
    complete_subets = subsets
    subsets_abrev = []
    for i in subsets:
        subsets_abrev.append(len(i))
    subsets = tuple(subsets_abrev)
    
    # Prepare parameters
    if isinstance(subsets, dict):
        subsets = [subsets.get(t, 0) for t in ['100', '010', '110', '001', '101', '011', '111']]
    areas = compute_venn3_areas(subsets, normalize_to)
    centers, radii = solve_venn3_circles(areas)
    ax = gca()
    prepare_venn3_axes(ax, centers, radii)
    result = []
    for (c, r) in zip(centers, radii):
        circle = Circle(c, r, alpha=alpha, edgecolor=color, facecolor='none', linestyle=linestyle, linewidth=linewidth, **kwargs)
        ax.add_patch(circle)
        result.append(circle)
    return result 
开发者ID:nsalomonis,项目名称:altanalyze,代码行数:31,代码来源:matplotlib_venn.py

示例6: check_vcf

# 需要导入模块: import matplotlib_venn [as 别名]
# 或者: from matplotlib_venn import venn3 [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") 
开发者ID:wdecoster,项目名称:nano-snakemake,代码行数:15,代码来源:venn_survivor_calls.py

示例7: SimpleMatplotVenn

# 需要导入模块: import matplotlib_venn [as 别名]
# 或者: from matplotlib_venn import venn3 [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 ######### 
开发者ID:nsalomonis,项目名称:altanalyze,代码行数:52,代码来源:VennDiagram.py


注:本文中的matplotlib_venn.venn3方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。