0
$\begingroup$

I don't understand how Seaborn histplot's binwidth parameter works when the range is not an integer multiple of the bin width.

Consider, for example the following piece of code.

import seaborn as sns
irises = sns.load_dataset('iris', cache=False)
sns.histplot(data=irises, x='sepal_length', binrange=(4,8), binwidth=2.5, stat='density')
sns.histplot(data=irises, x='sepal_length', binrange=(4,8), binwidth=3, stat='density')

The first call to histplot generates the following plot.

binwidth with a value of 2.5

Whereas the second call generates the following plot.

binwidth with a value of 3

In either case the rectangles' width does not equal the specified bin width. In the first case the rectangles' width is less than the specified bin width, whereas in the second case the rectangle's width is greater than the specified bin width.

How does the histplot function determine the bin width?

$\endgroup$
1

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.