• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python pylab.pie函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中pylab.pie函数的典型用法代码示例。如果您正苦于以下问题:Python pie函数的具体用法?Python pie怎么用?Python pie使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: makePie

def makePie(values):
    # make a square figure and axes
    pylab.figure(1, figsize=(6, 6))

    # Initialise the data lists.
    labels = []
    fracs = []
    explode = []

    # Check who mined the most
    most = max(values.iterkeys(), key=(lambda key: values[key]))

    # values should be in a dictionary format with the pilot names as keys.
    for pilot in values:
        labels.append(pilot)
        fracs.append(values[pilot])
        if pilot == most:
            explode.append(0.05)
        else:
            explode.append(0)

    pylab.pie(fracs, explode=explode, labels=labels, autopct="%1.1f%%", shadow=True)

    pylab.savefig("images/ore.png", bbox_inches="tight")
    pylab.close()
开发者ID:EluOne,项目名称:Nema,代码行数:25,代码来源:nema.py


示例2: make_lexicon_pie

def make_lexicon_pie(input_dict, title):
    e = 0
    f = 0
    n = 0
    l = 0
    g = 0
    o = 0

    for word in input_dict.keys():
        label = input_dict[word]
        if label == "English":
            e += 1
        elif label == "French":
            f += 1
        elif label == "Norse":
            n += 1
        elif label == "Latin":
            l += 1
        elif label == "Greek":
            g += 1
        else:
            o += 1

    total = e + f + n + l + g + o
    fracs = [o/total, n/total, g/total, l/total, f/total, e/total]
    labels = 'Other', 'Norse', 'Greek', 'Latin', 'French', 'English'
    pl.figure(figsize=(6, 6))
    pl.axes([0.1, 0.1, 0.8, 0.8])
    pl.pie(fracs, labels=labels, autopct='%1.1f%%', shadow=True, startangle=90)
    pl.title(title)
    pl.show()
开发者ID:Trevortds,项目名称:Etymachine,代码行数:31,代码来源:Etymachine.py


示例3: create_pie_chart

    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))
开发者ID:ppizarror,项目名称:Hero-of-Antair,代码行数:32,代码来源:classtracker_stats.py


示例4: plot

    def plot(self):
        """Histogram of the tissues found

        .. plot::
            :include-source:
            :width: 80%

            from gdsctools import GenomicFeatures
            gf = GenomicFeatures() # use the default file
            gf.plot()


        """
        if self.colnames.tissue not in self.df.columns:
            return
        data = pd.get_dummies(self.df[self.colnames.tissue]).sum()
        data.index = [x.replace("_", " ") for x in data.index]
        # deprecated but works for python 3.3
        try:
            data.sort_values(ascending=False)
        except:
            data.sort(ascending=False)
        pylab.figure(1)
        pylab.clf()
        labels = list(data.index)
        pylab.pie(data, labels=labels)
        pylab.figure(2)
        data.plot(kind='barh')
        pylab.grid()
        pylab.xlabel('Occurences')

        # keep the try to prevent MacOS issue
        try:pylab.tight_layout()
        except:pass
        return data
开发者ID:saezrodriguez,项目名称:gdsctools,代码行数:35,代码来源:readers.py


示例5: main

def main():
    fig = pylab.figure(1, figsize=(6, 6))
    pylab.pie([s[1] for s in MARKET_SHARE],
              labels=[s[0] for s in MARKET_SHARE],
              autopct='%1.1f%%')
    fig.savefig('images/market-share.png')
    pylab.clf()
开发者ID:kpuputti,项目名称:thesis,代码行数:7,代码来源:plot.py


示例6: explode

	def explode(self, figure_name, data=[], explode=[], labels=(), title='a graph'):
		"""
			Use this function to visualize data as a explode

			Params:
				data: The data will be visualized.
				explode: The distance between each bucket of the data.
						 explode should be len(data) sequence or None.
				labels: The labels shows next to the bucket of the data.
				title: The title of the graph.
			Returns:
				save_name: str
					The file location of the result picture
		"""
		try:
			os.mkdir(self.save_path + '/explode')
		except:
			logging.warning('update explode in '+self.save_path)
		#Make the graph square.
		pylab.figure(1, figsize=(6,6))
		ax = pylab.axes([0.1, 0.1, 0.8, 0.8])
		pylab.title(title)
		pylab.pie(data, explode = explode, labels = labels,
			autopct = '%1.1f%%', startangle = 0)

		save_name = self.save_path + '/explode/' + figure_name
		pylab.savefig(save_name)
		pylab.clf()

		return self.request_path + '/explode/' + figure_name + '.png'
开发者ID:darkframemaster,项目名称:Coding-Analysis,代码行数:30,代码来源:visualize.py


示例7: showResults

def showResults(request):
    Y_tally = 0
    N_tally = 0
    results_list = Choice.objects.all()
    
    for object in results_list:
        if object.votes == '1':
            Y_tally = Y_tally + 1
        else:
            N_tally = N_tally + 1
    

    # make a square figure and axes
    f = figure(figsize=(6,6))
    ax = axes([0.1, 0.1, 0.8, 0.8])
    #labels = 'Yes', 'No'
    labels = 'Yes', 'No'
    fracs = [Y_tally,N_tally]
    explode=(0, 0)
    pie(fracs, explode=explode, labels=labels, autopct='%1.1f%%', shadow=True)
    title('Election Results', bbox={'facecolor':'0.8', 'pad':5})
    canvas = FigureCanvasAgg(f)    
    response = HttpResponse(content_type='image/png')
    canvas.print_png(response)
    matplotlib.pyplot.close(f)
    f.clear()
    return response
开发者ID:Blitzace,项目名称:CTF,代码行数:27,代码来源:views.py


示例8: pie

    def pie(self):
        pylab.clf()
        keys = self.counter.keys()
        labels = dict([(k,float(self.counter[k])/len(self)) for k in keys])

        pylab.pie([self.counter[k] for k in keys], labels=[k +
            ':'+str(labels[k]) for k in keys])
开发者ID:WMGoBuffs,项目名称:biokit,代码行数:7,代码来源:seq.py


示例9: do_pie

def do_pie(prefix, dict, accesses):
	pylab.figure(1, figsize=(8,8))
	ax =  pylab.axes([0.1, 0.1, 0.8, 0.8])

	labels = []
	fracs = []
	rest = 0

	for item in dict.keys():
		frac = dict[item]

		if (float(frac)/float(accesses) > 0.01):
			labels.append(item)
			fracs.append(frac)
		else:
			rest += frac

	i = 0
	changed = False
	for x in labels:
		if x == 'undef':
			fracs[i] += rest
			labels[i] = 'other'
			changed = True
		i += 1

	if changed == False:
		labels.append('other')
		fracs.append(rest)

	pylab.pie(fracs, labels=labels, autopct='%1.1f%%', pctdistance=0.75, shadow=True)
	pylab.savefig('%s%s-%d-%02d-%02d.png' % (dest, prefix, y1, m1, d1))
	pylab.close(1)
开发者ID:docent-net,项目名称:mirrormanager,代码行数:33,代码来源:mirrorlist_statistics.py


示例10: plot_single

def plot_single(players, teamnum, teamname):
    total_matches = 0
    matches = {} # matches[player] = number of 1v1 games played
    info = {}
    wins = {}
    for player in players:
        if player.match:
            matches[player.character] = 0
            wins[player.character] = 0
            info[player.character] = (player.league, player.points, player.race)
            for match in player.match.keys():
                total_matches += 1
                matches[player.character] += 1
                if player.match[match][1]:
                    wins[player.character] += 1
            
    pylab.figure(1, figsize=(8,8))
    ax = pylab.axes([0.1, 0.1, 0.8, 0.8])
    
    labels = [] #sorted(matches.keys())
    fracs = []
    for key in sorted(matches.keys()):
        labels.append(key + '\n' + info[key][0] + ' ' + info[key][1] + ' (' + info[key][2] + ')\n' \
                + str(100 * wins[key]/ matches[key]) + '% win')
        fracs.append(100.0 * matches[key] / total_matches)
    #print str(labels)
    #print str(fracs)
    #print str(matches)

    explode = [0] * len(labels)
    colors = get_colors()
    pylab.pie(fracs, explode=explode, \
            labels=labels, colors=colors, autopct='%1.1f%%', shadow=True)
    pylab.title('1v1 Games Played ' + teamname)
    pylab.savefig(os.path.join(SAVEDIR, str(teamnum) + '_1v1games.png'))
开发者ID:dicai,项目名称:csl-analytics,代码行数:35,代码来源:get_stats.py


示例11: breakdownpie

def breakdownpie(projdict,datestart):
	pylab.figure(1, figsize=(6,6))
	ax = pylab.axes([0.1, 0.1, 0.8, 0.8])
	noaotime, chiletime, yaletime, lsutime = 0,0,0,0
	sunytime, gsutime, osutime, allotherstime = 0,0,0,0
	for key in projdict:
		if key.split('-')[0]=='NOAO':
			noaotime+=projdict[key]['time']
		elif key.split('-')[0]=='CHILE':
			chiletime+=projdict[key]['time']
		elif key.split('-')[0]=='YALE':
			yaletime+=projdict[key]['time']
		elif key.split('-')[0]=='LSU':
			lsutime+=projdict[key]['time']
		elif key.split('-')[0]=='SUNY':
			sunytime+=projdict[key]['time']
		elif key.split('-')[0]=='GSU':
			gsutime+=projdict[key]['time']
		elif key.split('-')[0]=='OSU':
			osutime+=projdict[key]['time']
		elif key.split('-')[0]!='STANDARD' and key.split('-')[0]!='STANDARDFIELD' and key.split('-')[0]!='ALL':
			allotherstime+=projdict[key]['time']

	times={"NOAO":noaotime, "CHILE":chiletime, "YALE":yaletime, "LSU":lsutime, "SUNY":sunytime, "GSU":gsutime, "OSU":osutime, "OTHERS":allotherstime}

	labels=[key for key in times if times[key] > 0]
	values=[times[key] for key in times if times[key] > 0]
	explode=[.05 for i in values]

	pylab.pie(values,labels=labels, autopct='%1.1f%%', explode=explode, startangle=90,  pctdistance=1.15, labeldistance= 1.3)

	pylab.savefig('images/'+datestart+'breakdown.png')
	plt.close()
	return
开发者ID:SMARTSconsortium,项目名称:nightreport,代码行数:34,代码来源:nr_charts.py


示例12: pie

def pie(df):
    classes = (df['class'].value_counts() / float(len(df)) * 100)
    classes.sort(ascending=False)
    classes = classes[classes > 1]

    pl.pie(list(classes) + [100 - classes.sum()], labels=list(classes.index) + ['OTHER'])
    pl.show()
开发者ID:katrielalex,项目名称:cdt-modelling,代码行数:7,代码来源:manipulate.py


示例13: generatePieChart

def generatePieChart(chartName, chartDataArray):
    '''generatePieChart will generate and display a pie chart using the provided data and title'''
    # Generate pie chart
    from pylab import figure, axes, pie, title, show

    # Get total number of data points
    total = len(chartDataArray)
    slices = []

    # Generate list of data "slices" and the quantity associated with each
    for item in chartDataArray:
        isNew = True
        for element in slices:
            if element[0] == item:
                element[1] += 1
                isNew = False
                break
        if isNew:
            slices.append([item, 1])

    # make a square figure and axes
    figure(1, figsize=(6,6))
    ax = axes([0.1, 0.1, 0.8, 0.8])

    # The slices will be ordered and plotted counter-clockwise.
    labels = [ str(x[0]) for x in slices ]
    fracs = [ 1.0 * x[1] / total for x in slices ]
    explode = []
    for x in range(len(slices)):
        explode.append(0.05)

    # Create and show the pie chart
    pie(fracs, labels=labels, explode=explode, autopct='%1.1f%%', shadow=True, startangle=90)
    title(chartName, bbox={'facecolor':'0.8', 'pad':5})
    show()
开发者ID:MyOwnSling,项目名称:ImageProfiler,代码行数:35,代码来源:GenerateExIFStats.py


示例14: violations_pie

def violations_pie():
	valid_places = [row for row in food_data if row['Violations'] !='' and 'No' not in row['Results'] and 'Not' not in row['Results'] and 'Out' not in row['Results']]
	problems = {}
	valid_places.sort(key =lambda r: r['DBA Name'])
	places_group = groupby(valid_places, key =lambda r: r['DBA Name'])
	for place,group in places_group:
		all_viols =""
		for row in group:
			all_viols += row['Violations']+'|'
		l = all_viols.split('|')
		l=[item.strip() for item in l]
		problems[place] = len(l)

	import operator
	sorted_list= sorted(problems.items(), key= operator.itemgetter(1), reverse=True )
	sorted_list =sorted_list[:5]
	print type(sorted_list)
	pie_parts=[]
	labels = []
	for item in sorted_list:
		labels.append(item[0])
		pie_parts.append(item[1])
	import pylab
	pylab.pie(pie_parts, labels=labels, autopct='%0.1f%%')
	pylab.show()
开发者ID:sreeragsreenath,项目名称:python-scripts,代码行数:25,代码来源:pie.py


示例15: pie_packages

def pie_packages(**kwargs):
    gpk = getpackages(**kwargs)
    n_packages = gpk.count()
    n_packages_uptodate_main = gpk.filter(n_versions=F('n_packaged')).count()
    n_packages_uptodate_all = gpk.filter(n_versions=F('n_packaged') + \
                              F('n_overlay')).count()
    n_packages_outdated = n_packages - n_packages_uptodate_all
    n_packages_uptodate_ovl = n_packages_uptodate_all - \
                              n_packages_uptodate_main

    pylab.figure(1, figsize=(3.5, 3.5))

    if n_packages_uptodate_ovl:
        labels = 'Ok (gentoo)', 'Ok (overlays)', 'Outdated'
        fracs = [n_packages_uptodate_main, n_packages_uptodate_ovl,
                 n_packages_outdated]
        colors = '#008000', '#0B17FD', '#FF0000'
    else:
        labels = 'Ok (gentoo)', 'Outdated'
        fracs = [n_packages_uptodate_main, n_packages_outdated]
        colors = '#008000', '#FF0000'

    pylab.pie(fracs, labels=labels, colors=colors, autopct='%1.1f%%',
              shadow=True)
    pylab.title('Packages', bbox={'facecolor': '0.8', 'pad': 5})
开发者ID:EvaSDK,项目名称:euscan,代码行数:25,代码来源:charts.py


示例16: plot_question

def plot_question(fname, question_text, data):
    import pylab
    import numpy as np
    from matplotlib.font_manager import FontProperties
    from matplotlib.text import Text
    pylab.figure().clear()
    pylab.title(question_text)
    #pylab.xlabel("Verteilung")
    #pylab.subplot(101)
    if True or len(data) < 3:
        width = 0.95
        pylab.bar(range(len(data)), [max(y, 0.01) for x, y in data], 0.95, color="g")
        pylab.xticks([i+0.5*width for i in range(len(data))], [x for x, y in data])
        pylab.yticks([0, 10, 20, 30, 40, 50])
        #ind = np.arange(len(data))
        #pylab.bar(ind, [y for x, y in data], 0.95, color="g")
        #pylab.ylabel("#")
        #pylab.ylim(ymax=45)
        #pylab.ylabel("Antworten")
        #pylab.xticks(ind+0.5, histo.get_ticks())
        #pylab.legend(loc=3, prop=FontProperties(size="smaller"))
        ##pylab.grid(True)
    else:
        pylab.pie([max(y, 0.1) for x, y in data], labels=[x for x, y in data], autopct="%.0f%%")
    pylab.savefig(fname, format="png", dpi=75)
开发者ID:digitalarbeiter,项目名称:web-survey-tdi,代码行数:25,代码来源:eval-surveys.py


示例17: pie_graph

def pie_graph(start_time,end_time,groupby,generate,**kwargs):
    start = time.time()
    graph_data = retrieve_date(start_time,end_time,groupby,generate,**kwargs)
    data_dict = Counter()
    for key,columns in graph_data:
        data_dict[columns[groupby]] +=columns[generate]
        #print columns[groupby],columns[generate]
    #pairs = zip(groupby_list,sum_generate_list)
    pairs = data_dict.items()
    pairs.sort(key=lambda x:x[1],reverse=True)
    groupby_list,sum_generate_list = zip(*pairs)
    groupby_list = list(groupby_list)
    sum_generate_list = list(sum_generate_list)
    #print type(groupby_list),type(sum_generate_list)
    if len(groupby_list)>10:
        groupby_list = groupby_list[:10]
        groupby_list.extend(['']*(len(sum_generate_list)-10))
    end = time.time()
    def my_display( x ):
        if x > 5:
            return '%.1f' % x + '%'
        else:
            return ""
    explode=[.0]*len(groupby_list)
    explode[0] = 0
    pylab.figure()
    pylab.pie(sum_generate_list,labels=groupby_list,autopct=my_display,shadow=False,explode=explode)
    pylab.title('%s groupby %s from %s to %s'%(generate,groupby,start_time,end_time))
    pylab.xlabel('Processing time is: %.5ss'%(end-start))
    pylab.savefig('foo.png')
    imgData = cStringIO.StringIO()
    pylab.savefig(imgData, format='png')
    imgData.seek(0)
    pylab.close()
    return imgData
开发者ID:zhangg,项目名称:Useless,代码行数:35,代码来源:pie_graph.py


示例18: pieChartCreation

def pieChartCreation(graph_size, fracs, name1, name2, colors):
    """
    Creates the big pie chart of the report. In this pie chart one fraction represents the amount of space
    sampled together by both trajectories, and the other two fractions represent the amount of space that was
    sampled by either A or B.

    @param graph_size: The graph size in pixels (?)
    @param fracs: a list or tuple containing the total number of elements of pure A, pure B, and mixed clusters.
    @param name1: String identifying the first trajectory.
    @param name2: String identifying the second trajectory.
    @param colors: dictionary with color descriptions for "A", "B" and "M" (Mixed) written in string format (for
    example "#FFFFFF" for white)

    @return : A PIL image of the pie chart.
    """
    all_labels = ["A","B","Mixed"]
    all_colors = [colors['A'], colors['B'],colors['M']]
    this_labels = []
    this_fracs = []
    this_colors = []
    mydpi = 100
    fig = pylab.figure(figsize=(int(graph_size[0]/mydpi),int(graph_size[1]/mydpi)),dpi = mydpi)
    fig.set_facecolor('white')
    for i in range(len(fracs)):
        if fracs[i]!=0:
            this_labels.append(all_labels[i])
            this_fracs.append(fracs[i])
            this_colors.append(all_colors[i])
    pylab.pie(this_fracs, labels=this_labels, autopct='%1.1f%%', shadow=False,colors=this_colors)
    pylab.title(shorten_name(name1)+" vs "+shorten_name(name2))
    return fig2img(fig)
开发者ID:lowks,项目名称:pyProCT,代码行数:31,代码来源:plotTools.py


示例19: plotdu

def plotdu():
    stats = diskused()
    
    figure(1, figsize=(7,7))
    ax = axes([0.1, 0.1, 0.8, 0.8])
    
    stage = os.environ['STAGE']
    id = subprocess.Popen('du -s '+stage+'/data/'+os.uname()[1]+'_data0/*', shell=True, stdout=subprocess.PIPE)
    duout = id.stdout.readlines()
    
    
    p = subprocess.Popen('ls '+stage+'/data/'+os.uname()[1]+'_data0/', shell=True, stdout=subprocess.PIPE)
    out = p.stdout.readlines()
    labels = ['free']
    dubyid = [stats['kb-free']]
    for i in range(0, len(out)):
        labels.append(out[i].split('\n')[0])
        dubyid.append(int(duout[i].split('\t')[0]))
    
    labels.append(os.uname()[1]+'_odexport/')
    od = subprocess.Popen('du -s '+stage+'/data/'+os.uname()[1]+'_odexport/', shell=True, stdout=subprocess.PIPE)
    odout = od.stdout.readlines()
    dubyid.append(int(odout[0].split('\t')[0]))

    fracs = dubyid

    #explode=(0, 0.05, 0, 0)
    pie(fracs, labels=labels, autopct='%1.1f%%', shadow=True)
    title(stats['project']+' Allocation', bbox={'facecolor':'0.8', 'pad':5})
    show()
开发者ID:badbytes,项目名称:pymeg,代码行数:30,代码来源:projectdu.py


示例20: displayMHSim

def displayMHSim(simResults, title):
    stickWins, switchWins = simResults
    pylab.pie([stickWins, switchWins],
              colors = ['r', 'c'],
              labels = ['stick', 'change'],
              autopct = '%.2f%%')
    pylab.title(title)
开发者ID:99701a0554,项目名称:courses-1,代码行数:7,代码来源:montyhall.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python pylab.plot函数代码示例发布时间:2022-05-25
下一篇:
Python pylab.pcolormesh函数代码示例发布时间:2022-05-25
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap