I was struggling a lot with creating a percentage histogram with seaborn and, recently, I came across this post on github, which was exactly what I was looking for. The argument stat='probability' normalises the data (stat='frequency' will give the same result) and outputs the desired plot. Reproducing the example of the last comment of the post, here's the graph:
tips = sns.load_dataset("tips")
sns.histplot(tips, x="day", hue="sex", stat="probability", multiple="fill", shrink=.8)
Any ideas whether it is possible to move the legend out?
I do not seem to have any access to the legend having tried with ax.legend(bbox_to_anchor=(1.05, 1), loc='upper left'), which disappear the labels. If I try to create new labels, I do not get the color differentiation the hue imposes.
I prefer to avoid an artist or reshaping the original dataframe to use matplotlib.
So, any input is very welcomed!