本篇文章為大家展示了如何在Python中利用matplotlib繪制餅狀圖,內(nèi)容簡明扼要并且容易理解,絕對(duì)能使你眼前一亮,通過這篇文章的詳細(xì)介紹希望你能有所收獲。
1、云計(jì)算,典型應(yīng)用OpenStack。2、WEB前端開發(fā),眾多大型網(wǎng)站均為Python開發(fā)。3.人工智能應(yīng)用,基于大數(shù)據(jù)分析和深度學(xué)習(xí)而發(fā)展出來的人工智能本質(zhì)上已經(jīng)無法離開python。4、系統(tǒng)運(yùn)維工程項(xiàng)目,自動(dòng)化運(yùn)維的標(biāo)配就是python+Django/flask。5、金融理財(cái)分析,量化交易,金融分析。6、大數(shù)據(jù)分析。
一 代碼
import numpy as np import matplotlib.pyplot as plt #The slices will be ordered and plotted counter-clockwise. labels ='Frogs','Hogs','Dogs','Logs' sizes =[15,30,45,10] colors =['yellowgreen','gold','#FF0000','lightcoral'] #使餅狀圖中第2片和第4片裂開 explode =(0,0.1,0,0.1) fig = plt.figure() ax = fig.gca() ax.pie(np.random.random(4), explode=explode, labels=labels, colors=colors, autopct='%1.1f%%', shadow=True, startangle=90, radius=0.25, center=(0,0), frame=True) ax.pie(np.random.random(4), explode=explode, labels=labels, colors=colors, autopct='%1.1f%%', shadow=True, startangle=90, radius=0.25, center=(1,1), frame=True) ax.pie(np.random.random(4), explode=explode, labels=labels, colors=colors, autopct='%1.1f%%', shadow=True, startangle=90, radius=0.25, center=(0,1), frame=True) ax.pie(np.random.random(4), explode=explode, labels=labels, colors=colors, autopct='%1.1f%%', shadow=True, startangle=90, radius=0.25, center=(1,0), frame=True) #設(shè)置坐標(biāo)軸刻度 ax.set_xticks([0,1]) ax.set_yticks([0,1]) #設(shè)置坐標(biāo)軸刻度上顯示的標(biāo)簽 ax.set_xticklabels(["Sunny","Cloudy"]) ax.set_yticklabels(["Dry","Rainy"]) #設(shè)置坐標(biāo)軸跨度 ax.set_xlim((-0.5,1.5)) ax.set_ylim((-0.5,1.5)) #設(shè)置縱橫比相等 ax.set_aspect('equal') plt.show()
二 運(yùn)行結(jié)果
上述內(nèi)容就是如何在Python中利用matplotlib繪制餅狀圖,你們學(xué)到知識(shí)或技能了嗎?如果還想學(xué)到更多技能或者豐富自己的知識(shí)儲(chǔ)備,歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道。
本文標(biāo)題:如何在Python中利用matplotlib繪制餅狀圖-創(chuàng)新互聯(lián)
網(wǎng)頁鏈接:http://aaarwkj.com/article40/dipiho.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站內(nèi)鏈、網(wǎng)站建設(shè)、響應(yīng)式網(wǎng)站、微信公眾號(hào)、定制網(wǎng)站、外貿(mào)建站
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容