Mansour Zayer
Mansour Zayer

Reputation: 384

How to show percentage instead of count on my Seaborn displot y axis?

I have the following code:
sns.displot(data_df_cleaned, x='estimate_error', bins = [-30, -5, 5, 30, 80])
which plots the following simple histogram, but I want my y axis to report percentage. It is important that I do this with Seaborn, for which I couldn't find any answer in the documentation or stackoverflow.

enter image description here

Upvotes: 0

Views: 3054

Answers (1)

Mansour Zayer
Mansour Zayer

Reputation: 384

sns.Displot takes kind='hist' as default, and if a parameter from sns.histplot called stat is set such that stat='probability', the y axis shows percentage instead of count. So the answer is:

sns.displot(data_df_cleaned, x='estimate_error', bins = [-30, -5, 5, 30, 80], stat='probability')

Upvotes: 2

Related Questions