-
Notifications
You must be signed in to change notification settings - Fork 9
/
plot_utils.py
72 lines (50 loc) · 2.3 KB
/
plot_utils.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
64
65
66
67
68
69
70
71
72
import matplotlib.pyplot as plt
import numpy as np
plt.rcParams.update({'font.size': 18})
plt.rc('font', family='serif')
plt.style.use('seaborn-muted')
def plot_results(list_results):
Name_tilte = list_results[0]['dataset'] + " Autoencoder"
ColorsList = ['b', 'r', 'c', 'g', 'y', 'k', 'm', 'brown']
for i in range(len(list_results)):
list_results[i]['Color'] = ColorsList[i]
fig, ax = plt.subplots(figsize = (10,10))
fig.patch.set_facecolor('white')
for dict_save in list_results:
ax.plot(dict_save['timesCPU'], dict_save['train_losses'], label= dict_save['algorithm'], color = dict_save['Color'], linewidth=3)
# ax.grid(True)
lgd = plt.legend(frameon=True, loc = 'upper right', framealpha = 1, edgecolor = 'black', fancybox = False)
lgd.get_frame().set_linewidth(1.0)
for line in lgd.get_lines():
line.set_linewidth(3.0)
handles, labels = ax.get_legend_handles_labels()
ax.legend(reversed(handles), reversed(labels))
ax.set_ylabel('Training loss')
ax.set_xlabel('CPU time')
ax.spines['top'].set_visible(True)
ax.spines['right'].set_visible(True)
ax.xaxis.set_tick_params(top='on', direction='in', width=2)
ax.yaxis.set_tick_params(right='on', direction='in', width=2)
plt.title(Name_tilte, fontsize = 25, fontweight='normal')
plt.yscale("log")
plt.show()
fig, ax = plt.subplots(figsize = (10,10))
fig.patch.set_facecolor('white')
for dict_save in list_results:
ax.plot(dict_save['epochs'], dict_save['train_losses'], label= dict_save['algorithm'], color = dict_save['Color'], linewidth=3)
# ax.grid(True)
lgd = plt.legend(frameon=True, loc = 'upper right', framealpha = 1, edgecolor = 'black', fancybox = False)
lgd.get_frame().set_linewidth(1.0)
for line in lgd.get_lines():
line.set_linewidth(3.0)
handles, labels = ax.get_legend_handles_labels()
ax.legend(reversed(handles), reversed(labels))
ax.set_ylabel('Training loss')
ax.set_xlabel('Epochs')
ax.spines['top'].set_visible(True)
ax.spines['right'].set_visible(True)
ax.xaxis.set_tick_params(top='on', direction='in', width=2)
ax.yaxis.set_tick_params(right='on', direction='in', width=2)
plt.title(Name_tilte, fontsize = 25, fontweight='normal')
plt.yscale("log")
plt.show()