利用python实现周期财务统计可视化
作者:HustWolf 时间:2022-03-19 21:30:41
正文之前
上午给爸爸打了个电话庆祝他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))
其实就画了俩图,一个是折线图,一个饼图
最后总结出来的就是这样了。。
至于每天怎么做统计的,也放个样子出来。
每天花个几分钟统计下,然后隔段时间来做个统计,更清晰的知道自己最近花了多少钱,钱都去哪儿了。很有利于我脱离月光族的状态。。
来源:https://www.jianshu.com/p/4b21ba875343
标签:python,统计,可视化
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
python和bash统计CPU利用率的方法
2023-10-15 06:28:25
总结showModalDialog和showModelessDialog用法
2007-11-24 08:26:00
JS二维数组的定义说明
2023-08-23 15:09:45
JAVA正则表达式校验qq号码的方法
2023-08-09 02:54:25
![](https://img.aspxhome.com/file/2023/6/64936_0s.png)
用户体验量化方法研究(二)
2010-02-08 12:46:00
asp去除html的函数代码分析附实例说明
2023-07-02 20:09:18
Python2.x版本中基本的中文编码问题解决
2021-01-06 14:02:16
微信小程序实现日期时间筛选器
2023-08-29 00:51:37
![](https://img.aspxhome.com/file/2023/0/56000_0s.jpg)
关于ASP中的类class
2007-08-19 15:37:00
加密处理使密码更安全[CFS编码加密]
2008-03-19 13:30:00
python递归实现快速排序
2023-08-26 22:46:27
Codeigniter控制器controller继承问题实例分析
2023-11-23 04:15:31
TMDPHP 模板引擎使用教程
2023-11-15 03:21:56
![](https://img.aspxhome.com/file/2023/9/94489_0s.gif)
详述如何提高MySQL中数据装载效率
2009-10-26 10:27:00
SQL语句分组获取记录的第一条数据的方法
2012-08-21 10:58:39
精细分析 SQL server服务器的内存配置
2009-01-19 13:56:00
Python实现获取nginx服务器ip及流量统计信息功能示例
2023-08-03 02:03:26
PHP连接MySQL数据的操作要点
2023-06-20 09:31:16
谈ASP的未来
2009-03-24 20:35:00
PHP中Trait及其应用详解
2023-11-24 06:33:05
![](https://img.aspxhome.com/file/2023/8/111028_0s.jpg)