2

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. 
cesarteaser
  • 111
  • 1
  • 8
  • Isn't this answer helpful?[seaborn: Selected KDE bandwidth is 0. Cannot estimate density](https://stackoverflow.com/questions/60596102/seaborn-selected-kde-bandwidth-is-0-cannot-estimate-density) – r-beginners Aug 21 '20 at 02:28

1 Answers1

7

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).

Sad Vaseb
  • 299
  • 3
  • 10