Python matplotlib.pyplot.pie() Examples
The following are 30
code examples of matplotlib.pyplot.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
matplotlib.pyplot
, or try the search function
.
Example #1
Source File: main.py From wechat-analyse with MIT License | 7 votes |
def analyseSex(firends): sexs = list(map(lambda x:x['Sex'],friends[1:])) counts = Counter(sexs).items() counts = sorted(counts, key=lambda x:x[0], reverse=False) counts = list(map(lambda x:x[1],counts)) labels = ['Unknow','Male','Female'] colors = ['red','yellowgreen','lightskyblue'] plt.figure(figsize=(8,5), dpi=80) plt.axes(aspect=1) plt.pie(counts, labels=labels, colors=colors, labeldistance = 1.1, autopct = '%3.1f%%', shadow = False, startangle = 90, pctdistance = 0.6 ) plt.legend(loc='upper right',) plt.title(u'%s的微信好友性别组成' % friends[0]['NickName']) plt.show()
Example #2
Source File: test_axes.py From twitter-stock-recommendation with MIT License | 6 votes |
def test_pie_frame_grid(): # The slices will be ordered and plotted counter-clockwise. labels = 'Frogs', 'Hogs', 'Dogs', 'Logs' sizes = [15, 30, 45, 10] colors = ['yellowgreen', 'gold', 'lightskyblue', 'lightcoral'] # only "explode" the 2nd slice (i.e. 'Hogs') explode = (0, 0.1, 0, 0) plt.pie(sizes, explode=explode, labels=labels, colors=colors, autopct='%1.1f%%', shadow=True, startangle=90, wedgeprops={'linewidth': 0}, frame=True, center=(2, 2)) plt.pie(sizes[::-1], explode=explode, labels=labels, colors=colors, autopct='%1.1f%%', shadow=True, startangle=90, wedgeprops={'linewidth': 0}, frame=True, center=(5, 2)) plt.pie(sizes, explode=explode[::-1], labels=labels, colors=colors, autopct='%1.1f%%', shadow=True, startangle=90, wedgeprops={'linewidth': 0}, frame=True, center=(3, 5)) # Set aspect ratio to be equal so that pie is drawn as a circle. plt.axis('equal')
Example #3
Source File: test_axes.py From python3_ios with BSD 3-Clause "New" or "Revised" License | 6 votes |
def test_pie_textprops(): data = [23, 34, 45] labels = ["Long name 1", "Long name 2", "Long name 3"] textprops = dict(horizontalalignment="center", verticalalignment="top", rotation=90, rotation_mode="anchor", size=12, color="red") _, texts, autopct = plt.gca().pie(data, labels=labels, autopct='%.2f', textprops=textprops) for labels in [texts, autopct]: for tx in labels: assert tx.get_ha() == textprops["horizontalalignment"] assert tx.get_va() == textprops["verticalalignment"] assert tx.get_rotation() == textprops["rotation"] assert tx.get_rotation_mode() == textprops["rotation_mode"] assert tx.get_size() == textprops["size"] assert tx.get_color() == textprops["color"]
Example #4
Source File: data_analysis.py From TextSentimentClassification with MIT License | 6 votes |
def label_distribution(trainFile): labels=[] with open(trainFile,'r') as f: raw_data=f.readlines() for line in raw_data: line=line.strip().split("+++$+++") label=int(line[2]) assert label in [0,1],"Invalid label value!" labels.append(label) neg_count=labels.count(0) pos_count=len(labels)-neg_count counts=[neg_count,pos_count] labels=["negative","positive"] fig=plt.figure(figsize=(9,9)) # 画饼图(数据,数据对应的标签,百分数保留两位小数点) plt.pie(counts, labels=labels, autopct='%1.2f%%') plt.title('Train Label Distribution', bbox={'facecolor': '0.8', 'pad': 5}) plt.show() savePath=trainFile.split(".")[0]+"_ld.png" fig.savefig(savePath) plt.close()
Example #5
Source File: GUI.py From Glaucoma-Detection with MIT License | 6 votes |
def graph(): total = len(os.listdir(test_path)) affected = pandas.read_csv('output.csv') affected = affected['output'].sum() healthy = total - affected piey = ['Glaucomatous', 'Healthy'] piex = [affected, healthy] plt.axis('equal') plt.pie(piex, labels=piey, radius=1.5, autopct='%0.1f%%', explode=[0.2, 0]) plt.show() # Frontend GUI
Example #6
Source File: test_axes.py From coffeegrindsize with MIT License | 6 votes |
def test_pie_center_radius(): # The slices will be ordered and plotted counter-clockwise. labels = 'Frogs', 'Hogs', 'Dogs', 'Logs' sizes = [15, 30, 45, 10] colors = ['yellowgreen', 'gold', 'lightskyblue', 'lightcoral'] explode = (0, 0.1, 0, 0) # only "explode" the 2nd slice (i.e. 'Hogs') plt.pie(sizes, explode=explode, labels=labels, colors=colors, autopct='%1.1f%%', shadow=True, startangle=90, wedgeprops={'linewidth': 0}, center=(1, 2), radius=1.5) plt.annotate("Center point", xy=(1, 2), xytext=(1, 1.5), arrowprops=dict(arrowstyle="->", connectionstyle="arc3")) # Set aspect ratio to be equal so that pie is drawn as a circle. plt.axis('equal')
Example #7
Source File: graphicsData.py From tieba-zhuaqu with GNU General Public License v3.0 | 6 votes |
def pieGraphics(Labels,ValueList,graphicTitle='图例'): # The slices will be ordered and plotted counter-clockwise. #labels = 'Frogs', 'Hogs', 'Dogs', 'Logs' #sizes = [15, 30, 45, 10] colors = ['yellowgreen', 'gold', 'lightskyblue', 'lightcoral', "blue","green","cyan","magenta"] explode = (0, 0.1, 0, 0) # only "explode" the 2nd slice (i.e. 'Hogs') plt.pie(ValueList, labels=Labels, colors=colors,autopct='%1.1f%%', shadow=True, startangle=90) # Set aspect ratio to be equal so that pie is drawn as a circle. plt.axis('equal') plt.show() #barGraphics('等级','数量',['A','B','C','D','E','F'],[29,30,40,47,38,23],'测试图例') #linePlotGraphics("xLabel","yLabel",[1,2,3,4,5,6,7,8,9,10],[1.1,1.9,2.6,3.6,9.8,14,24,40,80,150],graphicTitle='图例') #scatterPlotsGraphics("xLabel","yLabel",[1,2,3,4,5,6,7,8,9,10],[1,11.9,2,6.3,6,9.8,14,4,8,5],graphicTitle='图例')
Example #8
Source File: graphicsData.py From tieba-zhuaqu with GNU General Public License v3.0 | 6 votes |
def pieGraphics(Labels,ValueList,graphicTitle='图例'): colors = ['yellowgreen', 'gold', 'lightskyblue', 'lightcoral', "blue","green","cyan","magenta"] maxdata = max(ValueList) explode = [] for v in ValueList: if v == maxdata: explode.append(0.1) else: explode.append(0) print(explode) patches,l_text,p_text = plt.pie(ValueList, labels=Labels, colors=colors,autopct='%1.1f%%',explode=explode ,shadow=True, startangle=90) for font in l_text: font.set_fontproperties(FontProperties(fname=PATH_SUFFIX+'SIMLI.TTF')) plt.title(graphicTitle,fontproperties=font_set,y=1.05) # Set aspect ratio to be equal so that pie is drawn as a circle. plt.axis('equal') plt.show()
Example #9
Source File: graphicsData.py From tieba-zhuaqu with GNU General Public License v3.0 | 6 votes |
def pieGraphics(Labels,ValueList,graphicTitle='图例'): colors = ['yellowgreen', 'gold', 'lightskyblue', 'lightcoral', "blue","green","cyan","magenta"] maxdata = max(ValueList) explode = [] for v in ValueList: if v == maxdata: explode.append(0.1) else: explode.append(0) print(explode) patches,l_text,p_text = plt.pie(ValueList, labels=Labels, colors=colors,autopct='%1.1f%%',explode=explode ,shadow=True, startangle=90) for font in l_text: font.set_fontproperties(FontProperties(fname=PATH_SUFFIX+'SIMLI.TTF')) plt.title(graphicTitle,fontproperties=font_set,y=1.05) # Set aspect ratio to be equal so that pie is drawn as a circle. plt.axis('equal') plt.show()
Example #10
Source File: test_axes.py From coffeegrindsize with MIT License | 6 votes |
def test_pie_textprops(): data = [23, 34, 45] labels = ["Long name 1", "Long name 2", "Long name 3"] textprops = dict(horizontalalignment="center", verticalalignment="top", rotation=90, rotation_mode="anchor", size=12, color="red") _, texts, autopct = plt.gca().pie(data, labels=labels, autopct='%.2f', textprops=textprops) for labels in [texts, autopct]: for tx in labels: assert tx.get_ha() == textprops["horizontalalignment"] assert tx.get_va() == textprops["verticalalignment"] assert tx.get_rotation() == textprops["rotation"] assert tx.get_rotation_mode() == textprops["rotation_mode"] assert tx.get_size() == textprops["size"] assert tx.get_color() == textprops["color"]
Example #11
Source File: graphicsData.py From tieba-zhuaqu with GNU General Public License v3.0 | 6 votes |
def pieGraphics(Labels,ValueList,graphicTitle='图例'): colors = ['yellowgreen', 'gold', 'lightskyblue', 'lightcoral', "blue","green","cyan","magenta"] maxdata = max(ValueList) explode = [] for v in ValueList: if v == maxdata: explode.append(0.1) else: explode.append(0) print(explode) patches,l_text,p_text = plt.pie(ValueList, labels=Labels, colors=colors,autopct='%1.1f%%',explode=explode ,shadow=True, startangle=90) for font in l_text: font.set_fontproperties(FontProperties(fname=PATH_SUFFIX+'SIMLI.TTF')) plt.title(graphicTitle,fontproperties=font_set,y=1.05) # Set aspect ratio to be equal so that pie is drawn as a circle. plt.axis('equal') plt.show()
Example #12
Source File: detectcore.py From ibeis with Apache License 2.0 | 6 votes |
def visualize_distributions(distro_dict, threshold=10): import matplotlib.pyplot as plt key_list = sorted(distro_dict.keys()) threshold_str = '%d+' % (threshold, ) label_list = [ threshold_str if key == threshold else str(key) for key in key_list ] size_list = [ distro_dict[key] for key in key_list ] color_list = ['yellowgreen', 'gold', 'lightskyblue', 'lightcoral'] explode = [0.0] + [0.0] * (len(size_list) - 1) plt.pie(size_list, explode=explode, labels=label_list, colors=color_list, autopct='%1.1f%%', shadow=True, startangle=90) plt.axis('equal') plt.show()
Example #13
Source File: analysis_jd_item.py From jd_analysis with GNU Lesser General Public License v3.0 | 6 votes |
def analysis_mobile(self): # self.record_result('<strong style="color: black; font-size: 24px;">正在分析该商品不同省份的购买量...</strong>') fig_size = plt.rcParams["figure.figsize"] plt.figure(figsize = (2.4, 2.4)) obj = self.data_frame['is_mobile'] obj = obj.value_counts() obj = obj.rename({1: '移动端', 0: 'PC'}) plt.pie(x = obj.values, autopct = '%.0f%%', radius = 0.7, labels = obj.index, startangle = 180) plt.title('该商品移动/ PC 购买比例') plt.tight_layout() filename = '%s_mobile.png' % self.product_id plt.savefig('%s/%s' % (utils.get_save_image_path(), filename)) plt.figure(figsize = fig_size) plt.clf() result = utils.get_image_src(filename = filename) self.record_result(result, type = 'image') # 分析购买后评论的时间分布
Example #14
Source File: errorplot.py From actions-for-actions with GNU General Public License v3.0 | 6 votes |
def plot(sizes,plotname): fig = plt.figure(figsize=(2.0,2.0),facecolor='white') ax = plt.subplot(111) psizes = ['%1.1f%%' % (x/sum(sizes)*100) for x in sizes] labels = [x+'\n'+y for x,y in zip(LABELS,psizes)] patches = plt.pie(sizes, colors=COLORS, labels=labels, shadow=False, startangle=90, labeldistance=0.7, wedgeprops={'linewidth': 4}) for pie_wedge in patches[0]: pie_wedge.set_edgecolor('white') for t in patches[1]: t.set_horizontalalignment('center') plt.axis('equal') plt.tight_layout() plt.savefig(plotname) print('saved plot to {}'.format(plotname)) plt.show() ###################################################### # Data processing
Example #15
Source File: test_axes.py From twitter-stock-recommendation with MIT License | 6 votes |
def test_pie_center_radius(): # The slices will be ordered and plotted counter-clockwise. labels = 'Frogs', 'Hogs', 'Dogs', 'Logs' sizes = [15, 30, 45, 10] colors = ['yellowgreen', 'gold', 'lightskyblue', 'lightcoral'] explode = (0, 0.1, 0, 0) # only "explode" the 2nd slice (i.e. 'Hogs') plt.pie(sizes, explode=explode, labels=labels, colors=colors, autopct='%1.1f%%', shadow=True, startangle=90, wedgeprops={'linewidth': 0}, center=(1, 2), radius=1.5) plt.annotate("Center point", xy=(1, 2), xytext=(1, 1.5), arrowprops=dict(arrowstyle="->", connectionstyle="arc3")) # Set aspect ratio to be equal so that pie is drawn as a circle. plt.axis('equal')
Example #16
Source File: graphicsData.py From tieba-zhuaqu with GNU General Public License v3.0 | 6 votes |
def pieGraphics(Labels,ValueList,graphicTitle='图例'): # The slices will be ordered and plotted counter-clockwise. #labels = 'Frogs', 'Hogs', 'Dogs', 'Logs' #sizes = [15, 30, 45, 10] colors = ['yellowgreen', 'gold', 'lightskyblue', 'lightcoral', "blue","green","cyan","magenta"] explode = (0, 0.1, 0, 0) # only "explode" the 2nd slice (i.e. 'Hogs') plt.pie(ValueList, labels=Labels, colors=colors,autopct='%1.1f%%', shadow=True, startangle=90) # Set aspect ratio to be equal so that pie is drawn as a circle. plt.axis('equal') plt.show() #barGraphics('等级','数量',['A','B','C','D','E','F'],[29,30,40,47,38,23],'测试图例') #linePlotGraphics("xLabel","yLabel",[1,2,3,4,5,6,7,8,9,10],[1.1,1.9,2.6,3.6,9.8,14,24,40,80,150],graphicTitle='图例') #scatterPlotsGraphics("xLabel","yLabel",[1,2,3,4,5,6,7,8,9,10],[1,11.9,2,6.3,6,9.8,14,4,8,5],graphicTitle='图例')
Example #17
Source File: display.py From notes with Apache License 2.0 | 5 votes |
def show_pie_image(): plt.figure(figsize=(10, 16)) size = [10, 25, 20, 45] colors = ["red", "green", "blue", "yellow"] explode = [0, 0.05, 0, 0.1] labels = ["apple", "pears", "grape", "bananas"] plt.pie( x=size, labels=labels, colors=colors, explode=explode ) plt.axis("equal") plt.show()
Example #18
Source File: test_axes.py From twitter-stock-recommendation with MIT License | 5 votes |
def test_pie_linewidth_0(): # The slices will be ordered and plotted counter-clockwise. labels = 'Frogs', 'Hogs', 'Dogs', 'Logs' sizes = [15, 30, 45, 10] colors = ['yellowgreen', 'gold', 'lightskyblue', 'lightcoral'] explode = (0, 0.1, 0, 0) # only "explode" the 2nd slice (i.e. 'Hogs') plt.pie(sizes, explode=explode, labels=labels, colors=colors, autopct='%1.1f%%', shadow=True, startangle=90, wedgeprops={'linewidth': 0}) # Set aspect ratio to be equal so that pie is drawn as a circle. plt.axis('equal') # Reuse testcase from above for a labeled data test data = {"l": labels, "s": sizes, "c": colors, "ex": explode} fig = plt.figure() ax = fig.gca() ax.pie("s", explode="ex", labels="l", colors="c", autopct='%1.1f%%', shadow=True, startangle=90, wedgeprops={'linewidth': 0}, data=data) ax.axis('equal') # And again to test the pyplot functions which should also be able to be # called with a data kwarg plt.figure() plt.pie("s", explode="ex", labels="l", colors="c", autopct='%1.1f%%', shadow=True, startangle=90, wedgeprops={'linewidth': 0}, data=data) plt.axis('equal')
Example #19
Source File: utils.py From CogAlg with MIT License | 5 votes |
def describe_recursion(frame): typ_cnt = [0, 0, 0, 0] for P_ in frame: for P in P_: if len(P[-2]) == 0 and len(P[-3]) == 0: continue typ = 2 * (~P[0]) + (len(P[-2]) > 0) typ_cnt[typ] += 1 labels = ['rng', 'rng_seg', 'der', 'der_seg'] plt.pie(typ_cnt, labels=labels)
Example #20
Source File: test_axes.py From twitter-stock-recommendation with MIT License | 5 votes |
def test_pie_ccw_true(): # The slices will be ordered and plotted counter-clockwise. labels = 'Frogs', 'Hogs', 'Dogs', 'Logs' sizes = [15, 30, 45, 10] colors = ['yellowgreen', 'gold', 'lightskyblue', 'lightcoral'] explode = (0, 0.1, 0, 0) # only "explode" the 2nd slice (i.e. 'Hogs') plt.pie(sizes, explode=explode, labels=labels, colors=colors, autopct='%1.1f%%', shadow=True, startangle=90, counterclock=True) # Set aspect ratio to be equal so that pie is drawn as a circle. plt.axis('equal')
Example #21
Source File: test_axes.py From twitter-stock-recommendation with MIT License | 5 votes |
def test_pie_linewidth_2(): # The slices will be ordered and plotted counter-clockwise. labels = 'Frogs', 'Hogs', 'Dogs', 'Logs' sizes = [15, 30, 45, 10] colors = ['yellowgreen', 'gold', 'lightskyblue', 'lightcoral'] explode = (0, 0.1, 0, 0) # only "explode" the 2nd slice (i.e. 'Hogs') plt.pie(sizes, explode=explode, labels=labels, colors=colors, autopct='%1.1f%%', shadow=True, startangle=90, wedgeprops={'linewidth': 2}) # Set aspect ratio to be equal so that pie is drawn as a circle. plt.axis('equal')
Example #22
Source File: visualizing_data.py From data-science-from-scratch with MIT License | 5 votes |
def make_chart_pie_chart(plt): plt.pie([0.95, 0.05], labels=["Uses pie charts", "Knows better"]) # make sure pie is a circle and not an oval plt.axis("equal") plt.show()
Example #23
Source File: report.py From YouTube-Report with MIT License | 5 votes |
def score(self): print("Calculating Your Activity Score.....") colors = ["#ff3300", "#33cc33"] score_value = round( math.log( ( len(urls) + len(search_clean * 2) + len(all_likes * 3) + len(all_links * 4) ) / 9, 1.12, ), 1, ) x_0 = [1, 0, 0, 0] pl.pie([100 - score_value, score_value], autopct="%1.1f%%", startangle=90, colors=colors, pctdistance=10) plt.pie(x_0, radius=0.7, colors="w") plt.axis("equal") plt.title("Your YouTube Activity Score", fontsize=21, color="steelblue", fontweight="bold", fontname="Arial") plt.annotate(score_value, (0, 0), (123, 154), fontsize=54, color="teal", fontweight="bold", fontname="Arial", xycoords="axes fraction", textcoords="offset points", va="top") plt.savefig(os.path.join(image_dir,"score.png"), dpi=400) plt.clf()
Example #24
Source File: plot.py From libri-light with MIT License | 5 votes |
def plot_pie(data, pathOut, title=""): labels = list(data.keys()) sizes = [data[x] for x in labels] plt.clf() plt.style.use('classic') patches, texts, _ = plt.pie(sizes, autopct=lambda p: '{:.0f}'.format(p * sum(sizes) / 100), shadow=False, startangle=90, pctdistance=1.1) #plt.axes([0.3, 0.3, .5, .5]) plt.legend(patches, labels, loc='lower right', fontsize=8) plt.tight_layout() plt.title(title) plt.savefig(pathOut, bbox_inches='tight')
Example #25
Source File: visualizing_data.py From data-science-from-scratch with MIT License | 5 votes |
def make_chart_pie_chart(): plt.pie([0.95, 0.05], labels=["Uses pie charts", "Knows better"]) # make sure pie is a circle and not an oval plt.axis("equal") plt.show()
Example #26
Source File: step3.py From mexican-government-report with MIT License | 5 votes |
def plot_donut(df): """Generates a donut plot with the counts of 3 categories. Parameters ---------- df : pandas.DataFrame The DataFrame to be plotted. """ # We will only need 3 categories and 3 values. labels = ["Positivo", "Negativo", "Neutro"] positive = len(df[df["score"] > 0]) negative = len(df[df["score"] < 0]) neutral = len(df[df["score"] == 0]) values = [positive, negative, neutral] colors = ["green", "orange", "yellow"] explode = (0, 0, 0) # Explode a slice if required plt.rcParams["font.size"] = 18 plt.rcParams["legend.fontsize"] = 20 plt.pie(values, explode=explode, labels=None, colors=colors, autopct='%1.1f%%', shadow=False) # We draw a circle in the Pie chart to make it a donut chart. centre_circle = plt.Circle( (0, 0), 0.75, color="#5C0E10", fc="#5C0E10", linewidth=0) fig = plt.gcf() fig.gca().add_artist(centre_circle) plt.axis("equal") plt.legend(labels) plt.savefig("donut.png", facecolor="#5C0E10")
Example #27
Source File: test_axes.py From ImageFusion with MIT License | 5 votes |
def test_pie_linewidth_0(): # The slices will be ordered and plotted counter-clockwise. labels = 'Frogs', 'Hogs', 'Dogs', 'Logs' sizes = [15, 30, 45, 10] colors = ['yellowgreen', 'gold', 'lightskyblue', 'lightcoral'] explode = (0, 0.1, 0, 0) # only "explode" the 2nd slice (i.e. 'Hogs') plt.pie(sizes, explode=explode, labels=labels, colors=colors, autopct='%1.1f%%', shadow=True, startangle=90, wedgeprops={'linewidth': 0}) # Set aspect ratio to be equal so that pie is drawn as a circle. plt.axis('equal')
Example #28
Source File: sentry.py From marvin with BSD 3-Clause "New" or "Revised" License | 5 votes |
def get_pie_data(self, data): ''' Return the labels and sizes needed for the pie chart ''' labels = [v[0] for v in data] sizes = [v[1] for v in data] return labels, sizes
Example #29
Source File: sentry.py From marvin with BSD 3-Clause "New" or "Revised" License | 5 votes |
def plot_pie(self, key, data=None): ''' Makes a matplotlib pie chart for a given tag key ''' if self.tagvals and key in self.tagvals: vals = self.tagvals[key] labels = [v['name'] for v in vals] sizes = [v['count'] for v in vals] elif key == 'place': assert data is not None, 'Must provide some data to extract' vals = self.count_data(data) labels, sizes = self.get_pie_data(vals) elif key == 'baseurl': vals = self.tagvals['url'] names = [v['name'] for v in vals] labels = set(['sas' if 'sas.sdss.org' in n else 'api' for n in names]) stats = [{'type': 'web' if l == 'sas' else l, 'count': sum(d['count'] for d in vals if l in d['name'])} for l in set(labels)] labels = [s['type'] for s in stats] sizes = [s['count'] for s in stats] else: sizes = None raise NameError('No sizes or labels found. Make sure the data is somewhere') plt.clf() plt.pie(sizes, labels=labels, shadow=True, autopct='%1.1f%%', startangle=90) plt.axis('equal') plt.tight_layout() plt.show()
Example #30
Source File: errorplot.py From actions-for-actions with GNU General Public License v3.0 | 5 votes |
def main(subfile,plotname): # read in ground truth, and plot the distribution # of the top scores for each class sub = loadfile(subfile) subdict = dict(sub) with open(GTFILE) as f: reader = csv.DictReader(f) for row in reader: aid = row['id'] length = float(row['length']) Nframes = FPS*int(length) actions = parse_actions(row['actions']) frames = np.linspace(0,length,25) framenumber = np.linspace(0,Nframes,25) for f,sec,fnum in zip(range(1,26),frames,framenumber): analyze(subdict,actions,aid,f,sec,fnum) pies = [] for c in range(157): scores = det[c] scores.sort(key=lambda x: -x[2]) scores = scores[:100] # pick the top 100 scores for this class tp = sum(1 for x in scores if x[4]=='tp') bnd = sum(1 for x in scores if x[4]=='bnd') fb = sum(1 for x in scores if x[4]=='fb') obj = fb/2.+sum(1 for x in scores if x[4]=='obj') vrb = fb/2.+sum(1 for x in scores if x[4]=='vrb') fo = sum(1 for x in scores if x[4]=='fo') fp = sum(1 for x in scores if x[4]=='fp') pie = [tp, bnd, obj, vrb, fo, fp] pies.append(pie) sizes = [sum(x) for x in zip(*pies)] #combine results for all classes plot(sizes,plotname)