码迷,mamicode.com
首页 > 其他好文 > 详细

auther tonyxiao

时间:2018-07-07 15:37:43      阅读:141      评论:0      收藏:0      [点我收藏+]

标签:画图   第一个   index   mat   实例化   ant   一个   打开   列表   

 1 # -*- coding: utf-8 -*-
 2 
 3 #auther tonyxiao
 4 import xlrd
 5 
 6 workbook = xlrd.open_workbook(D:/Desktop/workload.xls) # 打开excel数据表
 7 SheetList = workbook.sheet_names() # 读取电子表到列表
 8 SheetName = SheetList[0] # 读取第一个电子表的名称
 9 Sheet1 = workbook.sheet_by_index(0) # 电子表索引从0开始
10 Sheet1 = workbook.sheet_by_name(SheetName) # 实例化电子表对象
11 
12 
13 a = 0
14 b = 0
15 c = 0
16 d = 0
17 e = 0
18 f = 0
19 g = 0
20 for i in range(Sheet1.nrows):
21     rows = Sheet1.row_values(i)
22     if rows[5] == suzu - Suo Zhu:
23         a += 1
24     if rows[5] == fxia - Feng Xiao:
25         b += 1
26     if rows[5] == wyql - David Liu:
27         c += 1
28     if rows[5] == jnug - Jingyuan Gu:
29         d += 1
30     if rows[5] == ruim - Ruiming Ma:
31         e += 1
32     if rows[5] == ckul - Kun Li:
33         f += 1
34 print(suzu - Suo Zhu, a)
35 print(fxia - Feng Xiao, b)
36 print(wyql - David Liu, c)
37 print(jnug - Jingyuan Gu, d)
38 print(ruim - Ruiming Ma, e)
39 print(ckul - Kun Li, f)
40 #画图
41 import numpy as np 
42 import matplotlib.mlab as mlab 
43 import matplotlib.pyplot as plt 
44 
45 X=[1,2,3,4,5,6]
46 Y=[a,b,c,d,e,f] 
47 fig = plt.figure()
48 plt.bar(X,Y,0.4,color="green")
49 plt.xlabel("name")
50 plt.ylabel("ticket quantity")
51 plt.title("workload chart")
52 
53 plt.show() 
54 plt.savefig("barChart.jpg")

 

auther tonyxiao

标签:画图   第一个   index   mat   实例化   ant   一个   打开   列表   

原文地址:https://www.cnblogs.com/latefall/p/9277118.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!