赞
踩
def plot_mc_curve(px, py, save_dir='mc_curve.png', names=(), xlabel='Confidence', ylabel='Metric'): # Metric-confidence curve font = {'family': 'Times New Roman', 'weight': 'normal', 'size': 23} fig, ax = plt.subplots(1, 1, figsize=(9, 6), tight_layout=True) plt.tick_params(labelsize=20)#刻度字的大小 if 0 < len(names) < 21: # display per-class legend if < 21 classes for i, y in enumerate(py): ax.plot(px, y, linewidth=1, label=f'{names[i]}') # plot(confidence, metric) else: ax.plot(px, py.T, linewidth=1, color='grey') # plot(confidence, metric) y = py.mean(0) ax.plot(px, y, linewidth=3, color='blue', label=f'all classes {y.max():.2f} at {px[y.argmax()]:.3f}') ax.set_xlabel(xlabel,fontsize=30,family='Times New Roman') ax.set_ylabel(ylabel,fontsize=30,family='Times New Roman') #print() labels = ax.get_xticklabels() + ax.get_yticklabels() [label.set_fontname('Times New Roman') for label in labels]#刻度字的字体 ax.set_xlim(0, 1) ax.set_ylim(0, 1) plt.legend( loc='best',prop=font)#小图的字体及大小 fig.savefig(Path(save_dir), dpi=200)
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。