-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdraw_gram.py
More file actions
58 lines (47 loc) · 907 Bytes
/
draw_gram.py
File metadata and controls
58 lines (47 loc) · 907 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# -*- coding: utf-8 -*-
# @Time : 2021/8/16 11:48
# @Author : beyoung
# @Email : linbeyoung@stu.pku.edu.cn
# @File : draw_gram.py
import matplotlib.pyplot as plt
# 获取列表的第二个元素
def takeSecond(elem):
return int(elem[0])
def gram(x_list, y_list):
# plt.plot([1,2,3,4],[1,4,9,11])
plt.plot(x_list, y_list)
plt.xticks(range(0, 24, 1))
# plt.yticks(range(0, 22, 2))
plt.ylabel('some numbers')
plt.show()
data = [('13', 41) ,
('12', 35) ,
('22', 32) ,
('17', 31) ,
('14', 26) ,
('18', 24) ,
('19', 21) ,
('16', 19) ,
('23', 18) ,
('00', 17) ,
('20', 17) ,
('21', 17) ,
('15', 14) ,
('11', 11) ,
('01', 8) ,
('10', 7) ,
('02', 4) ,
('09', 4) ,
('08', 1) ,
('03', 1) ,
('24', 17) ,
]
data.sort(key=takeSecond)
x_s = []
y_s = []
for item in data:
x_s.append(int(item[0]))
y_s.append(int(item[1]))
# x_s.sort()
# y_s.sort()
gram(x_s, y_s)