正文之前

上午給爸爸打了個(gè)電話慶祝他50歲生日,在此之前搞了個(gè)大掃除,看了會(huì)知乎,到實(shí)驗(yàn)室已經(jīng)十一點(diǎn)多了。約喜歡的妹子吃飯失敗,以至于工作積極性收到了打擊,所以就寫個(gè)程序來(lái)統(tǒng)計(jì)下開(kāi)學(xué)十一天的財(cái)務(wù)消費(fèi)情況,更清楚的認(rèn)識(shí)自己。
正文
廢話不多說(shuō),先放代碼:
import matplotlib.pyplot as plt
import matplotlib
from pylab import mpl
plt.rcParams['font.sans-serif']=['SimHei']
def getAll(x):
s=0
for i in x:
s+=i
return s
sump = [374.9,70,85.5,72.9,33.7,14.8,35.4,30.1,66.52,114.3,-13]
fruit = [0,0,0,10,0,0,0,0,35,0,0]
other = [338.6,50,53.8,49.5,10,0,0,0,6.42,92,-34]
food = []
for i in range(len(sump)):
food.append(sump[i] - fruit[i] - other[i])
date = []
for i in range(11):
date.append("8."+str(i+14))
plt.xlabel(u"時(shí)間")
plt.ylabel(u"消費(fèi)")
plt.plot(date,sump)
plt.plot(date,fruit)
plt.plot(date,other)
plt.plot(date,food)
plt.legend()
plt.show()
sump_all = getAll(sump)
fruit_all = getAll(fruit)
other_all = getAll(other)
food_all = getAll(food)
plt.figure(figsize=(6,9)) #調(diào)節(jié)圖形大小
labels = [u'Food '+str(int(food_all)),u'Fruit '+str(fruit_all),u'Other '+str(other_all)] #定義標(biāo)簽
sizes = [food_all,fruit_all,other_all] #每塊值
colors = ['red','yellowgreen','lightskyblue'] #每塊顏色定義
explode = (0,0,0) #將某一塊分割出來(lái),值越大分割出的間隙越大
patches,text1,text2 = plt.pie(sizes,
explode=explode,
labels=labels,
colors=colors,
autopct = '%3.2f%%', #數(shù)值保留固定小數(shù)位
shadow = False, #無(wú)陰影設(shè)置
startangle =90, #逆時(shí)針起始角度設(shè)置
pctdistance = 0.6) #數(shù)值距圓心半徑倍數(shù)距離
#patches餅圖的返回值,texts1餅圖外label的文本,texts2餅圖內(nèi)部的文本
# x,y軸刻度設(shè)置一致,保證餅圖為圓形
plt.axis('equal')
plt.show()
print("十天合計(jì)消費(fèi):%d"%(fruit_all+other_all+food_all))
網(wǎng)站題目:利用python實(shí)現(xiàn)周期財(cái)務(wù)統(tǒng)計(jì)可視化-創(chuàng)新互聯(lián)
轉(zhuǎn)載來(lái)于:http://chinadenli.net/article22/coghcc.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供標(biāo)簽優(yōu)化、App開(kāi)發(fā)、虛擬主機(jī)、網(wǎng)站維護(hù)、網(wǎng)站排名、品牌網(wǎng)站建設(shè)
聲明:本網(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í)需注明來(lái)源: 創(chuàng)新互聯(lián)