Python pylab.pie() Examples
The following are 9
code examples of pylab.pie().
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
pylab
, or try the search function
.
![](https://www.programcreek.com/common/static/images/search.png)
Example #1
Source File: psicquic.py From bioservices with GNU General Public License v3.0 | 6 votes |
def show_pie(self): """a simple example to demonstrate how to visualise number of interactions found in various databases """ try: from pylab import pie, clf, title, show, legend except ImportError: from bioservices import BioServicesError raise BioServicesError("You must install pylab/matplotlib to use this functionality") labels = range(1, self.N + 1) print(labels) counting = [len(self.relevant_interactions[i]) for i in labels] clf() #pie(counting, labels=[str(int(x)) for x in labels], shadow=True) pie(counting, labels=[str(x) for x in counting], shadow=True) title("Number of interactions found in N databases") legend([str(x) + " database(s)" for x in labels]) show()
Example #2
Source File: piecharts.py From binaryanalysis with Apache License 2.0 | 5 votes |
def generateImages(picklefile, pickledir, filehash, imagedir, pietype): leaf_file = open(os.path.join(pickledir, picklefile), 'rb') (piedata, pielabels) = cPickle.load(leaf_file) leaf_file.close() pylab.figure(1, figsize=(6.5,6.5)) ax = pylab.axes([0.2, 0.15, 0.6, 0.6]) pylab.pie(piedata, labels=pielabels) pylab.savefig(os.path.join(imagedir, '%s-%s.png' % (filehash, pietype))) pylab.gcf().clear() os.unlink(os.path.join(pickledir, picklefile))
Example #3
Source File: classtracker_stats.py From pyFileFixity with MIT License | 5 votes |
def create_pie_chart(self, snapshot, filename=''): """ Create a pie chart that depicts the distribution of the allocated memory for a given `snapshot`. The chart is saved to `filename`. """ try: from pylab import figure, title, pie, axes, savefig from pylab import sum as pylab_sum except ImportError: return self.nopylab_msg % ("pie_chart") # Don't bother illustrating a pie without pieces. if not snapshot.tracked_total: return '' classlist = [] sizelist = [] for k, v in list(snapshot.classes.items()): if v['pct'] > 3.0: classlist.append(k) sizelist.append(v['sum']) sizelist.insert(0, snapshot.asizeof_total - pylab_sum(sizelist)) classlist.insert(0, 'Other') #sizelist = [x*0.01 for x in sizelist] title("Snapshot (%s) Memory Distribution" % (snapshot.desc)) figure(figsize=(8,8)) axes([0.1, 0.1, 0.8, 0.8]) pie(sizelist, labels=classlist) savefig(filename, dpi=50) return self.chart_tag % (self.relative_path(filename))
Example #4
Source File: plot_pie_indel_summaries.py From SelfTarget with MIT License | 5 votes |
def plotSumPie(all_result_outputs, label=''): merged_data = mergeSamples(all_result_outputs, ['Total reads'] + ALL_LABELS, data_label='perOligoCounts') for col in ALL_LABELS: merged_data[col + ' Perc'] = merged_data[col + ' Sum']*100.0/merged_data['Total reads Sum'] merged_data.to_csv('data_dump_indel_pie.txt',sep='\t',columns=['Oligo Id'] + [col + ' Perc' for col in ALL_LABELS]) pie_vals = [merged_data[col + ' Perc'].mean() for col in ALL_LABELS] PL.figure(figsize=(4,4)) PL.pie(pie_vals, labels=ALL_LABELS, autopct='%.1f', labeldistance=1.05, startangle=90.0, counterclock=False, colors=COLORS) PL.title('Average distribution\n of mutations\n per gRNA') PL.show(block=False) saveFig('pie_chart_cats')
Example #5
Source File: plot_pie_indel_summaries.py From SelfTarget with MIT License | 5 votes |
def plotMCIPie(all_result_outputs, label=''): mci_merged_data = mergeSamples(all_result_outputs, ['MCI Type','Most Common Indel'], data_label='perOligoMCI') mci_common = mci_merged_data.loc[(mci_merged_data['Most Common Indel']==mci_merged_data['Most Common Indel 2']) & (mci_merged_data['Most Common Indel']==mci_merged_data['Most Common Indel 3'])] pie_vals, pie_labels = [], [] for mci_type in ALL_LABELS: pie_vals.append(len(mci_common.loc[mci_common['MCI Type'] == mci_type])) pie_labels.append(mci_type) pie_vals.append(len(mci_merged_data)-len(mci_common)) pie_labels.append('Inconsistent\nbetween\nreplicates') PL.figure(figsize=(4,4)) PL.pie(pie_vals, labels=pie_labels, autopct='%.1f', labeldistance=1.05, startangle=90.0, counterclock=False, colors=COLORS) PL.title('Most frequent\nmutation per gRNA') PL.show(block=False) saveFig('pie_chart_cats_dominant')
Example #6
Source File: plot_i1_summaries.py From SelfTarget with MIT License | 5 votes |
def computePieDataWithAmbig(data,label='', norm='I1 Total'): merged_data = mergeWithIndelData(data) pie_labels = ['I1_Rpt Left Reads - NonAmb','Ambiguous Rpt Reads','I1_Rpt Right Reads - NonAmb','I1_NonRpt Reads'] labels = ['Repeated\nleft nucleotide', 'Ambiguous\n(Left = Right)', 'Repeated\nright nucleotide', 'Non-repeated\nnucleotide'] pie_data = {x: (merged_data[x]*100.0/merged_data[norm]).mean(axis=0) for x in pie_labels} PL.figure(figsize=(3,3)) PL.pie([pie_data[x] for x in pie_labels], labels=labels, autopct='%.1f', labeldistance=1.05, startangle=120.0, counterclock=False) PL.title('Single nucleotide insertions (I1)') PL.show(block=False) saveFig('ambig_pie_%s' % label) return pie_data, pie_labels, data['Total reads'].median()
Example #7
Source File: plot_i1_summaries.py From SelfTarget with MIT License | 5 votes |
def computeFractionWithI1Repeats(data, label=''): merged_data = mergeWithIndelData(data) pie_label = 'Oligos with I1 Repeats' perc_with_11Rpt = len(merged_data.loc[(merged_data['I1_Rpt Left Reads - NonAmb'] + merged_data['Ambiguous Rpt Reads'])> 0.0])*100.0/len(merged_data) pie_data = {pie_label:perc_with_11Rpt} PL.figure() PL.pie([perc_with_11Rpt, 1-perc_with_11Rpt], labels=[pie_label,'Oligos without I1 Repeats'], autopct='%.1f', labeldistance=1.05, startangle=90.0, counterclock=False) PL.title(label) PL.show(block=False) return pie_data, [pie_label], merged_data['Total reads'].median()
Example #8
Source File: plot_i1_summaries.py From SelfTarget with MIT License | 5 votes |
def plotDominantPieDataWithAmbig(all_result_outputs, label=''): pie_labels = ['I1_Rpt Left Reads - NonAmb','Ambiguous Rpt Reads','I1_Rpt Right Reads - NonAmb','I1_NonRpt Reads'] mci_merged_data = mergeSamples(all_result_outputs, [], data_label='i1IndelData') mci_merged_data['Equal MCI'] = (mci_merged_data['Most Common Indel']==mci_merged_data['Most Common Indel 2']) & (mci_merged_data['Most Common Indel']==mci_merged_data['Most Common Indel 3']) mci_common_i1 = mci_merged_data.loc[mci_merged_data['Equal MCI'] & (mci_merged_data['MCI Type'] == 'I1')] labels = ['Repeated\nleft nucleotide', 'Ambiguous\n(Left = Right)', 'Repeated\nright nucleotide', 'Non-repeated\nnucleotide'] pie_data = [] for label in pie_labels: is_rpt = lambda row: row['MCI Reads'] == row[label] pie_data.append(sum(mci_common_i1.apply(is_rpt,axis=1))*100.0/len(mci_common_i1)) PL.figure(figsize=(3,3)) PL.pie(pie_data, labels=labels, autopct='%.1f', labeldistance=1.05, startangle=180.0, counterclock=False) PL.title('Dominant single nucleotide insertions (I1)\n%d from %d gRNAs' % (len(mci_common_i1), len(mci_merged_data))) PL.show(block=False) saveFig('I1_dom_pie_3_rep')
Example #9
Source File: plot_pie_indel_summaries.py From SelfTarget with MIT License | 4 votes |
def plotD1(all_result_outputs, label=''): mci_merged_data = mergeSamples(all_result_outputs, [], data_label='perOligoMCI') mci_merged_data['Equal MCI'] = (mci_merged_data['Most Common Indel']==mci_merged_data['Most Common Indel 2']) & (mci_merged_data['Most Common Indel']==mci_merged_data['Most Common Indel 3']) mci_common = mci_merged_data.loc[mci_merged_data['Equal MCI']] pie_vals, pie_labels = [], [] dmci_data = mci_common.loc[(mci_common['MCI Type'] == 'D1')] #Note: type check discards equally most common indels spans_cutsite = lambda indel: tokFullIndel(indel)[2]['L'] < -1 and tokFullIndel(indel)[2]['R'] > 0 for nt in 'ATGC': is_mh = lambda alt_seq: len(alt_seq) >= 2 and alt_seq == (len(alt_seq)*nt) num_repeat_nt = len(dmci_data.loc[dmci_data['Altered Sequence'].apply(is_mh) & dmci_data['Most Common Indel'].apply(spans_cutsite)]) pie_vals.append(num_repeat_nt*100.0/len(dmci_data)) print(num_repeat_nt) pie_labels.append('Removal of %s\nfrom %s|%s' % (nt,nt,nt)) is_non_repeat = lambda seq: len(seq) < 2 or seq != (seq[0]*len(seq)) num_non_repeat = len(dmci_data.loc[dmci_data['Altered Sequence'].apply(is_non_repeat) | ~dmci_data['Most Common Indel'].apply(spans_cutsite)]) pie_vals.append(num_non_repeat*100.0/len(dmci_data)) print(num_non_repeat) pie_labels.append('Removal from non-repeat') PL.figure(figsize=(4,4)) PL.pie(pie_vals, labels=pie_labels, autopct='%.1f', labeldistance=1.1, counterclock=False, colors=OLD_COLORS) PL.title('Size 1 deletions that are\n"most common" for their gRNA in all 3 replicates\n(%d gRNAs from %d total)' % (len(dmci_data), len(mci_merged_data))) PL.show(block=False) saveFig('pie_chart_D1') oligo_data = pd.read_csv(getHighDataDir() + '/ST_June_2017/data/self_target_oligos_details_with_pam_details.csv',sep='\t') remove_under = lambda x: x.replace('_','') oligo_data['Oligo Id'] = oligo_data['ID'].apply(remove_under) merged_mci_data = pd.merge(mci_merged_data, oligo_data[['Oligo Id','Guide']], how='inner',on='Oligo Id') print(len(merged_mci_data)) nt_dbl_perc_d1, cnt_labels = [], [] is_d1 = lambda indel: (indel.split('_')[0] == 'D1') non_dbl_nt = lambda row: row['Guide'][-4] != row['Guide'][-3] nts = 'ATGC' for nt in nts: double_nt = lambda row: row['Guide'][-4:-2] == (nt+nt) dbl_data = merged_mci_data.loc[merged_mci_data.apply(double_nt,axis=1)] num_dbl_d1 = sum(dbl_data['Most Common Indel'].apply(is_d1) & dbl_data['Equal MCI'] & (dbl_data['Oligo Id']!='Oligo28137')) #Oligo28137: Corner case where a guide has CT|T and loses the C nt_dbl_perc_d1.append(num_dbl_d1*100.0/len(dbl_data)) cnt_labels.append('%d/%d' % (num_dbl_d1,len(dbl_data))) print(len(dbl_data)) non_dbl_data = merged_mci_data.loc[merged_mci_data.apply(non_dbl_nt,axis=1)] print(len(non_dbl_data)) num_non_dbl_d1 = sum(non_dbl_data['Most Common Indel'].apply(is_d1) & non_dbl_data['Equal MCI']) nt_dbl_perc_d1.append(num_non_dbl_d1*100.0/len(non_dbl_data)) cnt_labels.append('%d/%d' % (num_non_dbl_d1,len(non_dbl_data))) PL.figure() PL.bar(range(5), nt_dbl_perc_d1, width=0.8) for i, cnt in enumerate(cnt_labels): PL.text(i-0.3,nt_dbl_perc_d1[i]+5.0,cnt) PL.xticks(range(5), ['%s' % x*2 for x in nts] + ['Other']) PL.ylim((0,40)) PL.xlabel('Nucleotides on either side of cut site') PL.ylabel('Percent gRNAs with single nucleotide deletion\nas most common indel in all 3 replicates') PL.show(block=False) saveFig('D1_bar_3_rep')