-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot-fig.py
More file actions
49 lines (44 loc) · 1.13 KB
/
Copy pathplot-fig.py
File metadata and controls
49 lines (44 loc) · 1.13 KB
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
import matplotlib.pyplot as plt
import numpy as np
import math
import sys
import os
def main():
out_dir = 'plot'
try:
os.makedirs(out_dir)
except:
pass
input_file = sys.argv[1]
interval = int(sys.argv[2])
bound = int(sys.argv[3])
out_fig = './plot/' + input_file[:-4] + '.png'
# read data from file
x_list = []
y_list = []
with open(input_file) as f:
for line in f:
x, y = line.strip().split()
if int(y) < bound:
x_list.append(int(x))
y_list.append(int(y))
print(x_list)
# plot the figure
plt.figure(figsize=(6.4, 2))
# y轴的文本
plt.ylabel("Latency (cycles)")
plt.plot(x_list, y_list)
# 仅在y轴添加网格线
plt.grid(axis='y')
# 画出垂直的边界线,方便显示前后差异
for i in range(math.ceil(len(x_list)/interval)):
bar = interval * i
plt.axvline(x=bar, color='y')
# x轴的文本
plt.xlabel("Num of experiments")
plt.tight_layout()
plt.savefig(out_fig, dpi=600)
# 清空图纸
plt.clf()
if __name__ == "__main__":
main()