-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathplot.py
76 lines (64 loc) · 2.38 KB
/
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import matplotlib.pyplot as plt
import numpy as np
import pickle
# if plot two accuracy data with distribution
with open("result/acc_dist_rcjj.pickle", "rb") as f:
d1 = pickle.load(f)
with open("result/acc_dist_tcjj.pickle", "rb") as f:
d2 = pickle.load(f)
fig = plt.figure(figsize=(14,5))
ax1 = fig.add_subplot(111)
ax2 = ax1.twinx()
ax1.bar(d1[0], d1[1], color="grey", label="NoS")
ax2.plot(d1[2], d1[3], color="red", linewidth=2.0, marker=".", label="SAR(BLSTM)")
ax2.plot(d2[2], d2[3], color="blue", linewidth=2.0, marker=".", label="SAR(Transformer)")
h1, l1 = ax1.get_legend_handles_labels()
h2, l2 = ax2.get_legend_handles_labels()
# ax1.legend(h1+h2, l1+l2, loc='lower right', bbox_to_anchor=(1, 0), fontsize=18)
ax1.set_xlabel("Number of Characters", fontsize=20)
ax1.set_ylabel("Number of Sentences", fontsize=20)
ax2.set_ylabel("SAR", fontsize=20)
ax1.tick_params(labelsize=18)
ax2.tick_params(labelsize=18)
ax1.set_yticks(np.arange(0, 151, 30))
ax1.set_ylim(0, 150)
ax2.set_ylim(0, 100)
plt.tight_layout()
ax1.grid(True)
plt.show()
exit()
# if plot four accuracy data with distribution
with open("result/acc_dist_rcjj.pickle", "rb") as f:
d1 = pickle.load(f)
with open("result/acc_dist_tcjj.pickle", "rb") as f:
d2 = pickle.load(f)
with open("result/data_dist_rwjj_c.pickle", "rb") as f:
d3 = pickle.load(f)
with open("result/data_dist_twjj_c.pickle", "rb") as f:
d4 = pickle.load(f)
fig = plt.figure(figsize=(14,5))
ax1 = fig.add_subplot(111)
ax2 = ax1.twinx()
# ax2.plot(d1[0], d1[1], color="blue", marker=".", label="NoS")
ax1.bar(d1[0], d1[1], color="blue", label="NoS")
ax2.plot(d1[2], d1[3], color="red", marker=".", label="SAR(B)")
ax2.plot(d2[2], d2[3], color="green", marker=".", label="SAR(T)")
ax2.plot(d3[2], d3[3], color="darkorange", marker=".", label="SAR(B)")
ax2.plot(d4[2], d4[3], color="yellowgreen", marker=".", label="SAR(T)")
h1, l1 = ax1.get_legend_handles_labels()
h2, l2 = ax2.get_legend_handles_labels()
ax1.legend(h1+h2, l1+l2, loc='upper left', bbox_to_anchor=(1.1, 1), fontsize=18)
ax1.set_xlabel("Number of Characters", fontsize=20)
ax1.set_ylabel("Number of Senteneces", fontsize=20)
# ax1.xlim()
ax2.set_ylim(0,100)
ax1.tick_params(labelsize=18)
# ax1.xaxis.set_ticks(np.arange(0, 100, 10))
ax1.grid(True)
# ax2.ylim()
ax2.tick_params(labelsize=18)
ax2.set_ylabel("SAR", fontsize=20)
plt.tight_layout()
# plt.tick_params(labelsize=13)
plt.show()
exit()