KDE off-diagonal marine cartridge with two classes

I'm trying to take a look at the Seaborn parachute for two different classes of variables, and I would like to see KDE on offdiagal instead of a diffused screen. The documentation has instructions on how to make KDE for all data , but I want to see separate KDE for each data subclass. Suggestions are welcome!

My code looks something like this:

plot = sns.pairplot( df, vars=labels, hue='has_accident', palette='Set1', diag_kind='kde', ) 

that leads to:

enter image description here

As you can see, the data is quite dense, which makes it difficult to see the difference in the red and blue data diagonally.

+6
source share
1 answer

Perhaps you mean something like this:

 import seaborn as sns import matplotlib.pyplot as plt iris = sns.load_dataset("iris") g = sns.PairGrid(iris, hue="species", hue_kws={"cmap": ["Blues", "Greens", "Reds"]}) g = g.map_diag(sns.kdeplot, lw=3) g = g.map_offdiag(sns.kdeplot, lw=1) plt.show() 

enter image description here

+9
source

Source: https://habr.com/ru/post/1014692/


All Articles