2

I am working on a data set of House Pricing - Advanced Regression . To Visualize my data after some cleaning I used sns.distplot() but its showing "FutureWarning: distplot is a deprecated function and will be removed in a future version." Here is code when I used distplot()

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns


num_var = ['MSSubClass', 'LotArea', 'OverallQual', 'OverallCond',
       'YearBuilt', 'YearRemodAdd', 'MasVnrArea', 'BsmtFinSF1', 'BsmtFinSF2',
       'BsmtUnfSF', 'TotalBsmtSF', '1stFlrSF', '2ndFlrSF', 'LowQualFinSF',
       'GrLivArea', 'BsmtFullBath', 'BsmtHalfBath', 'FullBath', 'HalfBath',
       'BedroomAbvGr', 'KitchenAbvGr', 'TotRmsAbvGrd', 'Fireplaces',
       'GarageYrBlt', 'GarageCars', 'GarageArea', 'WoodDeckSF', 'OpenPorchSF',
       'EnclosedPorch', '3SsnPorch', 'ScreenPorch', 'PoolArea', 'MiscVal',
       'MoSold', 'YrSold', 'SalePrice']

plt.figure(figsize=(25,25))
for i,var in enumerate(num_var):
    plt.subplot(9,4,i+1)
    sns.distplot(df[var],bins=20)
    sns.distplot(df3_drop_rows[var],bins=20)


#num_var = columns of my data
#df = Original data
#df3_drop_rows = Data After cleaning ( Simple cleaning just droped some rows and columns )

I got this output enter image description here

So then I tried to use displot() instead of distplot() after going through documentation and some stack overflow Answers then I changed my code to this

num_var = ['MSSubClass', 'LotArea', 'OverallQual', 'OverallCond',
       'YearBuilt', 'YearRemodAdd', 'MasVnrArea', 'BsmtFinSF1', 'BsmtFinSF2',
       'BsmtUnfSF', 'TotalBsmtSF', '1stFlrSF', '2ndFlrSF', 'LowQualFinSF',
       'GrLivArea', 'BsmtFullBath', 'BsmtHalfBath', 'FullBath', 'HalfBath',
       'BedroomAbvGr', 'KitchenAbvGr', 'TotRmsAbvGrd', 'Fireplaces',
       'GarageYrBlt', 'GarageCars', 'GarageArea', 'WoodDeckSF', 'OpenPorchSF',
       'EnclosedPorch', '3SsnPorch', 'ScreenPorch', 'PoolArea', 'MiscVal',
       'MoSold', 'YrSold', 'SalePrice']

plt.figure(figsize=(25,25))
for i,var in enumerate(num_var):
    plt.subplot(9,4,i+1)
    sns.displot(data=df[var],kde=True)
    sns.displot(data=df3_drop_rows[var],kde=True)

I got this output after doing some correction enter image description here

But my Issue is , I want output like first image i.e I want to plot both of my original data and cleaned data in one graph and all 36 graphs in ( 9 rows , 4 columns ) format.

Mr. T
  • 11,960
  • 10
  • 32
  • 54
  • 3
    You have mainly two options. One is to downgrade your seaborn to a previous version. The other is to [emulate the internal procedures of the old distplot](https://stackoverflow.com/q/67638590/8881141). – Mr. T Feb 28 '22 at 03:50
  • 2
    You need `sns.histplot(...., kde=True)` as a more close replacement of `distplot`. Note that `displot()` is a figure-level function, meant to create a complete grid in one go (but you'd need a "long form" dataframe). As a figure-level function, `sns.displot` creates its own new figure, ignoring the figure created with `plt.figure()` – JohanC Feb 28 '22 at 18:03

0 Answers0