我想把线性回归图和残差图一个挨着一个可视化--这可能吗?我知道如何把它们分开画,但谁能帮我把它们画在同一画布上?这是我的尝试,但第一张图已经画好了,而第二张图却留有空白。我得到错误信息。'AxesSubplot'对象没有属性'sns'。
fig1, ax = plt.subplots(1, 2, figsize=(12, 3))
ax[0].scatter(X_train, y_train, color = 'red')
ax[0].plot(X_train, lm1.predict(X_train), color = 'blue')
ax[0].set_title('Simple Linear Regression')
ax[0].set_xlabel('highway-mpg')
ax[0].set_ylabel('price')
ax[1].sns.residplot(df['highway-mpg'], df['price'])
ax[1].set_title('Residual plot')
ax[1].set_xlabel('highway-mpg')
ax[1].set_ylabel('price')