Ner*_*eto 2 python regression seaborn
我想使用 Seaborn 绘制适合我的数据集的线性回归模型。
由于该数据集在水柱中具有不同的深度(底部、中部和顶部),我希望我的图具有 3 种不同的颜色,但线性回归将针对整个数据集。我划分了这个数据集以分别绘制它们,如下所示:
fig, axarr = plt.subplots(3, sharex = True)
axarr[0].scatter(averageOBSB_3min,PumpBotSSC,c='r', label='Bottom')
axarr[0].scatter(averageOBSM_3min,PumpMidSSC,c='g', label='Middle')
axarr[0].scatter(averageOBST_3min,PumpTopSSC,c='b', label='Top')
Run Code Online (Sandbox Code Playgroud)
但显然这对 Seaborn 不起作用。
我的问题是:如何在绘图上使用不同的颜色,但对孔数据集进行回归?
混合使用 Seaborn 的lmplot和regplot:
import seaborn as sns
#Use lmplot to plot scatter points
graph = sns.lmplot(x='x_value', y='y_value', hue='water_value', data=df, fit_reg=False)
#Use regplot to plot the regression line for the whole points
sns.regplot(x='x_value', y='y_value', data=df, scatter=False, ax=graph.axes[0, 0]))
Run Code Online (Sandbox Code Playgroud)