学习笔记10—Python 绘图集

时间:2022-04-01 21:10:53

ordered_data = np.load('ordered_data_just_TD_mae.npy')
results = pd.Series(np.squeeze(np.load('results_just_TD_mae.npy')))
sigma = pd.Series(np.squeeze(np.load('sigma_just_TD_mae.npy')))

print(np.argmin(results[1:80]))
print(np.min(results[1:80]))

x = np.linspace(0,80,80)
plt.plot(x,results,label = 'MAE')
plt.hold(True)
plt.fill_between(x,results-sigma,results+sigma,alpha=0.5, edgecolor='#CC4F1B', facecolor='#FF9848')
plt.annotate('',xy = (np.argmin(results[1:80]),results[np.argmin(results[1:80])]), xytext = (np.argmin(results[1:80]),3+results[np.argmin(results[1:80])]), arrowprops=dict(facecolor='red',shrink=20))
plt.text(np.argmin(results[1:80])-6,(results[np.argmin(results[1:80])]-1),r'MAE = %.2f'%results[np.argmin(results[1:80])],fontsize = 10)
plt.text(np.argmin(results[1:80])-5,(results[np.argmin(results[1:80])]+3.5),r'K = %d'%np.argmin(results[1:80]),fontsize = 10)
plt.xlabel('number of descriptors (K)')
plt.ylabel('MAE (years)')
plt.legend(['TD Data'], loc = 2, ncol = 1) # loc = 1 represent right, loc = 2 represent left, ncol = 1 represent 1 column