使用python做周期财务统计可视化

正文之前

上午给爸爸打了个电话庆祝他50岁生日,在此之前搞了个大扫除,看了会知乎,到实验室已经十一点多了。约喜欢的妹子吃饭失败,以至于工作积极性收到了打击,所以就写个程序来统计下开学十一天的财务消费情况,更清楚的认识自己。

正文

废话不多说,先放代码:

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"时间")
plt.ylabel(u"消费")
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)) #调节图形大小
labels = [u'Food '+str(int(food_all)),u'Fruit '+str(fruit_all),u'Other '+str(other_all)] #定义标签
sizes = [food_all,fruit_all,other_all] #每块值
colors = ['red','yellowgreen','lightskyblue'] #每块颜色定义
explode = (0,0,0) #将某一块分割出来,值越大分割出的间隙越大
patches,text1,text2 = plt.pie(sizes,
                      explode=explode,
                      labels=labels,
                      colors=colors,
                      autopct = '%3.2f%%', #数值保留固定小数位
                      shadow = False, #无阴影设置
                      startangle =90, #逆时针起始角度设置
                      pctdistance = 0.6) #数值距圆心半径倍数距离
#patches饼图的返回值,texts1饼图外label的文本,texts2饼图内部的文本
# x,y轴刻度设置一致,保证饼图为圆形
plt.axis('equal')
plt.show()

print("十天合计消费:%d"%(fruit_all+other_all+food_all))

其实就画了俩图,一个是折线图,一个饼图

最后总结出来的就是这样了。。

至于每天怎么做统计的,也放个样子出来。

每天花个几分钟统计下,然后隔段时间来做个统计,更清晰的知道自己最近花了多少钱,钱都去哪儿了。很有利于我脱离月光族的状态。。

正文之后

哎,妹子没约到,饭还是要吃的,上午搞了大扫除还没吃早饭,气

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 操场北边有几棵枇杷树,只要是早活动时间我就去看它们。 从虬枝吐绿到枝繁叶茂,从繁星点点到灿烂绽放,从落英缤纷到青涩...
    桃花流水宝二爷阅读 2,607评论 2 0
  • 我的玩具飞机 我有一架漂亮的玩具飞机,是爸爸给我买的。我对它爱不释手,因为它非常漂亮气派。它的机身大部分是黄色的,...
    585e169ea247阅读 2,600评论 0 0
  • 男同志又提要养宠物的事儿。烦。 前天刚拒绝过他一次,又提。干脆翻脸。 我现在坚决不想养宠物。以前我给他分析不能养的...
    S猫阅读 3,255评论 11 3
  • 洋芋,可能称之为马铃薯更确切一些,因为它确实酷似马铃铛的形状。叫洋芋,更多说明,它是一种外来物种,而土豆、这薯那薯...
    无为兮阅读 4,937评论 2 11