【发布时间】:2014-11-21 11:28:29
【问题描述】:
我必须制作适合我的数据的散点图和衬线。 prediction_08.Dem_Adv 和 prediction_08.Dem_Win 是两列数据。我知道 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
【问题讨论】:
标签: numpy matplotlib ipython-notebook