【发布时间】:2021-03-12 12:41:35
【问题描述】:
我是初学者,所以这可能是一个愚蠢的问题。如果我运行以下代码,我会看到 x 和 y 的散点图,但回归线 plt.plot(x, estimated_y, color="r", linewidth=3.0) 没有出现。我使用协方差矩阵估计了y。 x、y 和 estimated_y 都是 numpy 数组。如果我单独运行plt.plot(x, estimated_y, color="r", linewidth=3.0),我会看到一个空图。
plt.figure()
plt.scatter(x,y)
plt.plot(x, estimated_y, color="r", linewidth=3.0)
plt.show()
plt.xlabel("x")
plt.ylabel("y")
感谢大家的帮助!
【问题讨论】:
-
如果不显示整个代码和数据集,很难说你做了什么。首先:您确定
estimated_y包含数据并且在图的限制范围内吗?
标签: python matplotlib plot regression scatter-plot