-
Notifications
You must be signed in to change notification settings - Fork 1
/
plot.py
executable file
·35 lines (24 loc) · 864 Bytes
/
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
#!/usr/bin/env python3
import csv
import sys
import matplotlib.pyplot as plt
FIG_NAME = 'plot-{:05}.png'
def parse_csv(filename):
'Parses the given filename and returns a dict of run no to list of values.'
data = {}
with open(filename, newline='') as csv_file:
for row in csv.DictReader(csv_file):
run, signal = int(row['run']), float(row['signal'])
data.setdefault(run, []).append(signal)
return data
if __name__ == '__main__':
if len(sys.argv) == 1:
print('Useage: ./plot.py *.csv\n')
exit(1)
data = [(fn.rstrip('.csv'), parse_csv(fn)) for fn in sys.argv[1:]]
for run in data[0][1].keys():
for csv_set in data:
plt.plot(csv_set[1][run], alpha=0.5, label=csv_set[0])
plt.legend()
plt.savefig(FIG_NAME.format(run))
plt.gcf().clear()