Reputation: 2981
I'm attempting to plot the KDE each column in a dataframe df
, with the last column being a boolean with which I plot two hues on each graph, through the use of
sns.pairplot(df, hue='last', palette={True: "#FF0000", False: "#0000FF"}, diag_kind='kde')
This gives me nice KDEs for all of the columns. However, I don't really care for comparing each column pairwise; I only really want to see how the KDEs differ based on the value of last
. However, no other method is that elegant. The only other option I've seen is using a FacetGrid
, but that has the flaw that the axes limits are all the same. I just can't find a nice way to visualize each column and its relation to the last boolean column.
Upvotes: 4
Views: 3044
Reputation: 2981
I just needed to set sharex
and sharey
in the FacetGrid.__init__
to False
:
sns.FacetGrid(data=df.melt(id_vars=['last']), col="variable", hue="last",
palette={True: "#FF0000", False: "#0000FF"}, sharex=False,
sharey=False, col_wrap=4).map(sns.kdeplot, 'value', shade=True)
Upvotes: 3