How to resolve sns.pairplot error Selected KDE bandwidth is 0. Cannot estimate density"?

Viewed 2871

I am trying to plot two distributions on one plot. I like the pairplot format as it is NOT a histogram and it also shows the overlap of distributions nicely. However, when applying a pairplot for only 1 continuous and 1 categorical variable, it shows a strange formatting error I think. How do I either resolve this error OR use another plot type which shows the exact same chart? Also, how do I add a legend for the color coding?

Code: 
df=>df['Sales','Customer_type']
sb.pairplot(df, hue="Customer_type")

OUT: enter image description here

Following Error with the OUTPUT: RuntimeError: Selected KDE bandwidth is 0. Cannot estimate density. 
1 Answers

Pairplot sometimes give this error. You can define bandwide value to avoid the error. For example your code will look like:

sb.pairplot(df, hue="Customer_type", diag_kws={'bw': 0.2})

bw is the bandwidth. You should adjust bw. Larger bandwidth causes larger bin sizes (e.i., smooth density function) and small bandwidth causes small bin (more resolution).

Related