我的挑战是将自定义线函数图覆盖在我已经拥有的散点图上,代码如下所示:
base_beta = results.params
X_plot = np.linspace(0,1,400)
g = sns.FacetGrid(data, size = 6)
g = g.map(plt.scatter, "usable_area", "price", edgecolor="w")
其中base_beta
只有一个常数,然后是一个系数。基本上,我想覆盖一个绘制线条的函数y = constant + coefficient * x
我试图用它覆盖一条线,但它不起作用。
g = g.map_dataframe(plt.plot, X_plot, X_plot*base_beta[1]+base_beta[0], 'r-')
plt.show()
谁能帮我这个?
--尝试1
base_beta = results.params
X_plot = np.linspace(0,1,400)
Y_plot = base_beta [0] + base_beta[1]*X_plot
g = sns.FacetGrid(data, size = 6)
g = g.map(plt.scatter, "usable_area", "price", edgecolor="w")
plt.plot(X_plot, Y_plot, color='r')
plt.show()