/
probability_compare_plot.py
62 lines (46 loc) · 1.65 KB
/
probability_compare_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
61
62
import matplotlib
matplotlib.use('TkAgg')
import matplotlib.pyplot as plt
import pandas as pd
import numpy as np
def main():
csv_list = [
"Z:/data/intracranial/CFD_results/results_with_probability_dos.csv",
"Z:/data/intracranial/CFD_results/results_with_probability_selected.csv",
"Z:/data/intracranial/CFD_results/results_with_probability_all.csv"
]
input_types = ['DoS', 'CFD param' , 'CFD param all']
plot_fmt = ["-","--","-."]
colors = ["r","g","b"]
n_inputs = len(csv_list)
# create plot
fig, axs = plt.subplots(2,2,figsize=(5, 5))
plt.suptitle('Probability against DoS')
for i, _csv in enumerate(csv_list):
# load csv
result = pd.read_csv(_csv)
result = result.sort_values(by=['degree of stenosis(%)'])
result_X = result[[
"degree of stenosis(%)",
]]
result_Y_columns = [col for col in result.columns if 'probability' in col]
result_Y = result[result_Y_columns]
# # colormap
# cmap = matplotlib.cm.get_cmap('Paired',lut=8)
# colors = [cmap.hsv(x) for x in np.linspace(0, 1, 10)]
for j, col in enumerate(result_Y_columns):
ax = axs.flatten()[j]
result_Y[col] = result_Y[col].rolling(10).mean()
label = input_types[i]
# label = "{} {}".format(input_types[i] , col.split("_")[1])
# axs.flatten()[j].plot(result_X.to_numpy(), result_Y[col].to_numpy(), plot_fmt[i], label=label, color=cmap(2*i+j))
ax.set_title(col.split("_")[1])
ax.plot(result_X.to_numpy(), result_Y[col].to_numpy(), plot_fmt[0], label=label, color=colors[i])
ax.set_xlabel('degree of stenosis(%)')
ax.set_ylabel('probability of stroke')
ax.set_xlim(0,100)
ax.set_ylim(0,1)
ax.legend()
plt.show()
if __name__ == "__main__":
main()