This repository has been archived by the owner on Feb 22, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
line_graph.py
63 lines (47 loc) · 1.5 KB
/
line_graph.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
61
62
63
import numpy as np
import matplotlib.pyplot as plt
import matplotlib
from sys import argv, exit
if len(argv) < 5:
print("Usage: ./script WHICH AXIS_X AXIS_Y FILE [FILE, FILE, ...]")
print("WHICH = <column #>[,<column #>,...]")
print("AXIS_X = <x axis label>")
print("AXIS_Y = <y axis label>")
exit(-1)
WHICH = [int(x) for x in argv[1].split(',')]
AXIS_X = argv[2]
AXIS_Y = argv[3]
data = {}
for data_file in argv[4:]:
with open(data_file, 'r') as f:
data[data_file] = []
for line in f:
if len(line.strip()) == 0:
continue
#xs = [float(x)/1E6 for x in line.split()]
xs = [float(x) for x in line.split()]
data[data_file].append(xs)
handles = []
for data_file in data:
for i in WHICH:
if i < len(data[data_file][0]):
#ys = [x[i] - data[data_file][0][i] for x in data[data_file]]
# uncomment next line to prevent normalizing to X_0
ys = [x[i] for x in data[data_file]]
#xs = [float(i) / 1E6 for i in range(len(ys))]
#line, = plt.plot(xs, ys, label = data_file)
line, = plt.plot(ys, label = data_file)
handles.append(line)
#plt.xscale("log", basex = 2)
#plt.yscale(SCALE)
#plt.xlim(0, 512+32)
#plt.ylim(0, 600)
plt.xlabel(AXIS_X)
plt.ylabel(AXIS_Y)
plt.grid(True)
plt.legend(handles = handles, loc='best')
font = {'family' : 'normal',
'weight' : 'bold',
'size' : 22}
matplotlib.rc('font', **font)
plt.show()