1
$\begingroup$

I'm trying to do some PairPlots using seaborn, so I can compare a bunch of features against the label I'm trying to model. There are a bunch of features though (~50). So I'm basically doing:

g = sns.pairplot(train_df,x_vars=["MoSold","GarageArea","ScreenPorch","OverallQual"],y_vars="SalePrice",size=4)

Where "SalePrice" is the label that I want to compare the others against. For now I don't care about comparing the features to each other.

The problem I'm having, though, is that when I plot this in my Jupyter notebook, it formats it as one long row.

enter image description here

I'm only doing it with 4 features here, but when I add as many as I want to, it basically makes the row thinner and longer, and impossible to read (because it's trying to make them all share the same y axis).

What I'd like is for it to automatically wrap like panda's hist does:

enter image description here

I can think of a few little hacks. I could do several individual PairPlot commands to manually do it, using a for loop or something, but that would be kind of a pain. Is there some more elegant way to do this? Something where I'd specify the number of columns it'll display with, and then it'll make a grid, where the y axis is always SalePrice?

$\endgroup$
1
$\begingroup$

You should not use sns.pairplot which is for plotting all-by-all comparisons.

You should use sns.regplot which can specify particular comparisons to make. Then use subplots can control the tiling.

|improve this answer|||||
$\endgroup$
  • 1
    $\begingroup$ Can you kindly provide examples? $\endgroup$ – Deepak Shenoy Oct 13 '18 at 17:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.