Python matplotlib_venn.venn3() Examples
The following are 7
code examples of matplotlib_venn.venn3().
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: 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 #4
Source File: matplotlib_venn.py From altanalyze with Apache License 2.0 | 5 votes |
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))
Example #5
Source File: matplotlib_venn.py From altanalyze with Apache License 2.0 | 5 votes |
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
Example #6
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 #7
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 #########