2
我必須製作一個散點圖和襯裏,以適合我的數據。 prediction_08.Dem_Adv和prediction_08.Dem_Win是兩列數據。我知道np.polyfit返回係數。但是np.polyval在這裏做什麼?我看到了文檔,但解釋混亂。可有一個人給我解釋清楚解釋np.polyfit和np.polyval散點圖
plt.plot(prediction_08.Dem_Adv, prediction_08.Dem_Win, 'o')
plt.xlabel("2008 Gallup Democrat Advantage")
plt.ylabel("2008 Election Democrat Win")
fit = np.polyfit(prediction_08.Dem_Adv, prediction_08.Dem_Win, 1)
x = np.linspace(-40, 80, 10)
y = np.polyval(fit, x)
plt.plot(x, y)
print fit
明白了。感謝您的明確解釋。 – 2014-11-21 12:44:57
然後你可以通過點擊勾號來接受它作爲答案 – 2014-11-21 12:46:02