0
我想绘制回归拟合曲线。该曲线适用于更高阶多项式(6以上)。如何在matplotlib python中绘制多项式曲线?
fig=figure()
ax1=fig.add_axes((0.1,0.2,0.8,0.7))
ax1.set_title("Training data(blue) and fitting curve(red)")
ax1.set_xlabel('X-axis')
ax1.set_ylabel('Y-axis')
ax1.plot(x_train,y_train,'.',x_train,np.polyval(best_coef,x_train),'-r')
show()
This is the output of the given code
我想这是一条平滑的曲线。
something like this , with a continues red line , instead of discreet point of red
是否有'best_coef'来自?你写了这个吗? – wwii
我写了一个polyfit函数,它返回适合数据的最佳度数多项式的系数。 – ajithalbus