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