pythonmatplotlibhistogramseabornkernel-density

Seaborn pairplot kde diagonal default behavior


When using seaborn’s pairplot, I use the hue parameter which defaults diag_kind to 'kde'.

If I have 3 levels of “hues” or levels in my data, do the areas under each of the kde curves equal 1 (similar to matplotlib stacked=False)? Or is it that the areas under all 3 curves combined equal 1 (similar to matplotlib stacked=True)?

I’m trying to visualize the distribution of the 3 levels separately, so I’m hoping the area under each of the curves is equal to 1. If this is not the default behavior, is there a way to make it so?


Solution

  • The accepted answer is wrong, its result will not produce individually normalized densities. The correct way to do this is by supplying a diag_kws argument:

    import seaborn as sns
    
    penguins = sns.load_dataset("penguins")
    sns.pairplot(penguins, diag_kind="kde", hue="species", diag_kws=dict(common_norm=False))
    

    Result