Lets say I have a dataframe such as:
CATEGORY Value
a v1
a v2
a v3
a v4
a v5
b v6
b v7
b v8
Now, if i want to plot this distributions by category, i could use something like:
sns.histplot(data,"Value",hue="CATEGORY",stat="percent").
The problem with this is that category "a" represents 5/8 of the sample and "b" is 3/8. The histograms will reflect this. I want to plot in a way that each histogram will have an area of 1, instead of 5/8 and 3/8.
Below is an example of how it looks like now
But each of those areas should be one.
I thought of maybe iterating by category and plotting one by one
As per this answer of the duplicate, use
common_norm=False
.Also see seaborn histplot and displot output doesn't match.
This is not specific to
stat='percent'
. Other options are'frequency'
,'probability'
, and'density'
.sns.displot