#曲线拟合
fig = plt.figure()
ax = fig.add_subplot(111)#将画布分割成1行1列,图像画在从左到右从上到下的第1块 ax.plot(Num,a,label=u'A',color='m',linestyle='',marker='.')
ax.plot(Num,b,label=u'B',color='g',linestyle='',marker='.')
#计算多项式
c=np.polyfit(Num,a,100)#拟合多项式的系数存储在数组c中
yy=np.polyval(c,Num)#根据多项式求函数值
c2=np.polyfit(Num,b,100)#拟合多项式的系数存储在数组c中
yy2=np.polyval(c2,Num)#根据多项式求函数值
#进行曲线绘制
x_new=np.linspace(0, 360)
f_liner=np.polyval(c,x_new)
f_liner2=np.polyval(c2,x_new)
ax.plot(x_new,f_liner,label=u'A',color='g',linestyle='-',marker='')
ax.plot(x_new,f_liner2,label=u'B',color='b',linestyle='-',marker='')
# labels标签设置
ax.set_xlim(0, 366)
ax.set_xlabel(u'T')
ax.set_ylabel(u'Values of A/B')
ax.set_title(u'A/B By T', bbox={'facecolor':'0.8', 'pad':5})
ax.legend()
plt.show()
#