设为首页收藏本站

EPS数据狗论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

查看: 1710|回复: 0

[数据可视化] 数据可视化

[复制链接]

20

主题

162

金钱

264

积分

入门用户

发表于 2019-8-15 14:32:51 | 显示全部楼层 |阅读模式
  1. #画饼图
  2. def print_pie(input_data):
  3.     res = {}
  4.     for each in input_data:
  5.         res[each] = res.get(each, 0) + 1
  6.     label=[]
  7.     X=[]
  8.     for j in res:
  9.         label.append(j)
  10.         X.append(res[j])
  11.    
  12.     fig = plt.figure()
  13.     plt.pie(X,labels=label,autopct='%1.2f%%') #画饼图(数据,数据对应的标签,百分数保留两位小数点)
  14.     plt.title("Pie chart")
  15.     plt.show()  
  16. #
  17. #频率直方图
  18. plt.hist(df1['age'],100,normed=1,histtype='bar',facecolor='yellowgreen',alpha=0.75)
  19. plt.show()   
  20. #频率直方图
  21. plt.hist(df1['age'],100,normed=1,histtype='bar',facecolor='yellowgreen',alpha=0.75)
  22. plt.show()



  23. fig,(ax0,ax1) = plt.subplots(nrows=2,figsize=(9,6))  
  24. #第二个参数是柱子宽一些还是窄一些,越大越窄越密  
  25. ax0.hist(df1['age'],100,normed=1,histtype='bar',facecolor='yellowgreen',alpha=0.75)  

  26. ax0.set_title('YES')  
  27. ax1.hist(df2['age'],100,normed=1,histtype='bar',facecolor='PINK',alpha=0.75)  

  28. ax1.set_title("NO")  
  29. fig.subplots_adjust(hspace=0.4)  
  30. plt.show()
复制代码

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关闭

站长推荐上一条 /1 下一条

客服中心
关闭
在线时间:
周一~周五
8:30-17:30
QQ群:
653541906
联系电话:
010-85786021-8017
在线咨询
客服中心

意见反馈|网站地图|手机版|小黑屋|EPS数据狗论坛 ( 京ICP备09019565号-3 )   

Powered by BFIT! X3.4

© 2008-2028 BFIT Inc.

快速回复 返回顶部 返回列表