-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot_histo.py
More file actions
76 lines (60 loc) · 1.73 KB
/
plot_histo.py
File metadata and controls
76 lines (60 loc) · 1.73 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import os.path
import matplotlib.pyplot as plt
import pandas
direc = 'F:\PHD\HUMAN\Intact\Scan_Data\Histograms'
def get_data(file_list):
per_histo_list = []
histo_dict = {}
for file in file_list:
data = pandas.read_csv(
direc + '\\' + file,
header=None,
names=['GS', 'count'])
gs = data['GS']
count = data['count']
gs = gs.tolist()
count = count.tolist()
per_histo_list.append(gs)
per_histo_list.append(count)
# print(per_histo_list)
histo_dict[file[:-4]] = per_histo_list
per_histo_list = []
return histo_dict
def plot(data):
fig = plt.figure()
fig.suptitle('Histograms', fontsize=22)
ax = fig.add_axes([0.1, 0.1, 0.6, 0.75])
ax.set_yscale('log')
for a in data.keys():
ax.plot(
data[a][0],
data[a][1],
label=a[:-22],
linewidth=2)
# print(data[i * per_spec + a][2])
# print('i = ' + str(i) + ', a = ' + str(a))
ax.legend(
bbox_to_anchor=(1.05, 1.),
loc=2,
borderaxespad=0.,
fontsize=9)
plt.xlabel('GS')
plt.ylabel('Count')
plt.show()
# fname = direc + '/' + str(title) + '.' + str(file_type)
# if os.path.isfile(fname):
# print("File exists already")
# else:
# plt.savefig(fname, bbox_inches='tight')
plt.close()
if __name__ == "__main__":
os.chdir(direc)
list_of_csvs = []
# Scan through them separating them.
list_of_files = sorted(os.listdir(direc))
for file in list_of_files:
if ".csv" in file:
list_of_csvs.append(file)
print(file)
data_dict = get_data(list_of_csvs)
plot(data_dict)