-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathline_plot.py
60 lines (47 loc) · 1.37 KB
/
line_plot.py
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
59
60
#!/usr/bin/env python3
import argparse
import numpy as np
import matplotlib.pyplot as plt
from config import *
def main():
parser = argparse.ArgumentParser()
parser.add_argument(
"--data-path",
required=True,
type=str,
help="Data file path.",
)
parser.add_argument("--fig-size", nargs="+", type=int, default=(2, 2))
args = parser.parse_args()
color = [
COLOR["red"],
COLOR["blue"],
COLOR["purple"],
COLOR["yellow"],
COLOR["green"],
]
marker = [
MARKER["triangle"],
MARKER["circle"],
MARKER["cross"],
MARKER["plus"],
MARKER["diamond"],
]
# figure creation
fig, ax = plt.subplots(figsize=args.fig_size)
with open(args.data_path) as f:
x_list, y_list, label = None, None, None
for i, line in enumerate(f.read().splitlines()):
if i % 2 == 0:
line_arr = line.split(",")
y_list = [float(n) for n in line_arr[:-1]]
label = line_arr[-1]
else:
line_arr = line.split(",")
x_list = [float(n) for n in line_arr]
if i % 2 == 1:
ax.plot(x_list, y_list, color=color[i // 2], marker=marker[i // 2], label=label)
plt.tight_layout()
plt.savefig("line.png")
if __name__ == "__main__":
main()