【发布时间】:2023-04-07 02:30:02
【问题描述】:
我想通过将异常值更改为其他颜色来识别异常值,以便在去除异常值后,散点图的变化更清晰。
# TotalBsmtSF: Total square feet of basement area
fig = plt.figure(figsize=(16, 8))
ax1 = fig.add_subplot(211)
b = sns.scatterplot(x = 'TotalBsmtSF', y = 'SalePrice', data = df, ax=ax1,)
plt.title ('Total square feet of basement area VS SalePrice (With Outliers)', fontsize=13)
plt.tight_layout()
# Removing houses with total basement area which is more than 3000 square feet
df = df.drop(df[(df['TotalBsmtSF']>3000) & (df['SalePrice']>=160000)].index)
# print(df['TotalBsmtSF'].head(450))
ax2 = fig.add_subplot(212)
b = sns.scatterplot(x = 'TotalBsmtSF', y = 'SalePrice', data = df, ax=ax2,)
plt.title ('Total square feet of basement area VS SalePrice (Outliers Removed)', fontsize=13)
plt.tight_layout()
plt.close(2)
plt.close(3)
plt.tight_layout()
【问题讨论】:
标签: python seaborn scatter-plot outliers