def plot(self, ylim=None):
import matplotlib.patches as mpatches
import matplotlib.pyplot as plt
from pylab import subplot
number_of_subplots=len(self.scores.keys())
colors = ['blue', 'green', 'orange']
patches = []
for plot_idx, metric in enumerate(self.scores):
for i, set_name in enumerate(self.scores[metric].keys()):
data = self.scores[metric][set_name][0]
time = self.scores[metric][set_name][1]
patches.append(mpatches.Patch(color=colors[i], label='{0} {1}'.format(set_name, metric)))
ax1 = subplot(number_of_subplots,1,plot_idx+1)
ax1.plot(time,data, label='{0}'.format(metric), color=colors[i])
if ylim != None:
plt.ylim(ymin=ylim[0])
plt.ylim(ymax=ylim[1])
plt.xlabel('iter')
plt.ylabel('{0} {1}'.format(set_name, metric))
ax1.legend(handles=patches)
plt.show()
评论列表
文章目录