forked from toolleeo/special-section-processing
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SpecSecBoxPlot.py
56 lines (40 loc) · 1.36 KB
/
SpecSecBoxPlot.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
import sys
import matplotlib.pyplot as plt
import pandas as pd
import argparse
import csv
# Lettura del file csv con i valori di coerenza
def read_csv(file):
values_by_row = []
prefix = 'coherence_th'
with open(file, 'r') as csv_file:
reader = csv.reader(csv_file, delimiter='\t')
headers = next(reader)
col_ind = [i for i, col in enumerate(headers) if col.startswith(prefix)]
for row in reader:
columns = [float(row[i]) for i in col_ind]
values_by_row.append(columns)
return list(zip(*values_by_row))
# Creazione di un box plot
def create_boxplot(values, file_name):
plt.figure(figsize=(30, 15))
plt.boxplot(values)
plt.xlabel('Threshold', fontsize=20)
plt.ylabel('Values', fontsize=20)
path = 'SpecSec'
if 'fake' in file_name:
path += 'Fake_BoxPlot.png'
else:
path += '_BoxPlot.png'
plt.savefig(path)
plt.clf()
def main():
parser = argparse.ArgumentParser()
parser.add_argument('spec_sec_metrics', type=str, help='file con le metriche delle Special Section')
parser.add_argument('spec_sec_fake_metrics', type=str, help='file con le metriche delle Special Section')
args = parser.parse_args()
for item in sys.argv[1:]:
values = read_csv(item)
create_boxplot(values, item)
if __name__ == '__main__':
main()