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


Python pylab.pie函数代码示例

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


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


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