Reputation: 11
I got my housing data from kaggle. I am trying to do a pairplot using seaborn. However I am not sure why GrLivArea
graph output is blank.
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
df = pd.read_csv('train.csv')
sns.pairplot(df, x_vars=['GrLivArea', 'LotArea', 'TotalBsmtSF', 'GarageArea'], y_vars=['SalePrice'], height=8, aspect = 1, kind='reg')
plt.show()
Able to advise?
Upvotes: 1
Views: 621
Reputation: 31
I encounter the same problem when using sns.pairplot
.
Then I find the solution on Github
here.
By adding the parameter diag_kind=None
in the sns.pairplot
then the first plot could successfully build.
Upvotes: 2
Reputation: 182
This is because your x-axis for the first plot starts from 0.0 and goes till 1.0. If you do the following:
sns.pairplot(df, x_vars=['LotArea', 'TotalBsmtSF', 'GarageArea','GrLivArea'], y_vars=['SalePrice'], height=8, aspect = 1, kind='reg')
then the plot will be empty for LotArea.
At first, I assumed it was due to empty values (NaNs) in your dataset. But, I checked it, and it does not seem to be the case.
The following solution should solve your problem:
fig, axs = plt.subplots(ncols=4)
sns.regplot(x='GrLivArea', y='SalePrice', data=df, ax=axs[0])
sns.regplot(x='LotArea', y='SalePrice', data=df, ax=axs[1])
sns.regplot(x='TotalBsmtSF',y='SalePrice', data=df, ax=axs[2])
sns.regplot(x='GarageArea', y='SalePrice', data=df, ax=axs[3])
plt.show()
While it is not a pairplot, you can plot each regplot as a subplot.
Upvotes: 1