def plot_convergence(history, prefix='', prefix2=''):
plt.figure(figsize=(8, 5))
ax = plt.subplot(111)
ax.get_xaxis().tick_bottom()
ax.get_yaxis().tick_left()
plt.plot(history["TC"], '-', lw=2.5, color=tableau20[0])
x = len(history["TC"])
y = np.max(history["TC"])
plt.text(0.5 * x, 0.8 * y, "TC", fontsize=18, fontweight='bold', color=tableau20[0])
if history.has_key("additivity"):
plt.plot(history["additivity"], '-', lw=2.5, color=tableau20[1])
plt.text(0.5 * x, 0.3 * y, "additivity", fontsize=18, fontweight='bold', color=tableau20[1])
plt.ylabel('TC', fontsize=12, fontweight='bold')
plt.xlabel('# Iterations', fontsize=12, fontweight='bold')
plt.suptitle('Convergence', fontsize=12)
filename = '{}/summary/convergence{}.pdf'.format(prefix, prefix2)
if not os.path.exists(os.path.dirname(filename)):
os.makedirs(os.path.dirname(filename))
plt.savefig(filename, bbox_inches="tight")
plt.close('all')
return True
评论列表
文章目录