I have a problem with sns.histplot(). As far as I understand bins
parameter should indicate how many of bins should be in the plot. Here is some code to visualize the strange (at least for me) behavior.
d = {'col1': [1, 2, 3, 4, 5, 6, 7, 8, 9 , 10 , 11 , 12, 13, 14, 15], 'col2': [1, 1, 1, 1, 1, 1, 2, 2, 2 , 2 , 2, 2, 2, 2, 2]}
df = pd.DataFrame(data=d)
sns.histplot(data=df, x='col1', multiple='dodge', hue='col2', binwidth=2, bins=8)
I have almost same problem in my original code where i have
hist = sns.histplot(data=Data, x=y_data, multiple='dodge', ax=axes[0], hue=i[2][1], binwidth=2, bins=10)
And as You can see there is only one bin where data have its minimum and std but is not splitted into number of bins I declared. Can anyone explain me why this is not splitting data into provided number of bins ? How can I change code to ensure constant number of bins ?
CodePudding user response:
I think the problem is binwidth parameter. Maybe just try to delete that parameter, or set it to smaller value (0.2 or 0.1)
CodePudding user response:
From the docs, regarding the binwidth
parameter:
Width of each bin, overrides
bins
but can be used withbinrange
.
So you can't specify both bins
and binwidth
at the same time.