I have this code in Python:
df = pd.read_excel('data (1).xlsx')
x = np.array(df['biceps circumference (cm)'])
ax1 = sns.countplot(x="biceps circumference (cm)", data=df)
Where df is my data frame and "biceps circumference (cm)" is a column. I'm using seaborn's countplot function to make a frequency distribution. But, I want to change the number of bins and their size in the plot. Is there a way to do this?
CodePudding user response:
For a distribution Histplot will be more fitting and gives more flexibility.
Countplot can not show distributions it only can show absolute counts of categories and across categories.
bins = "auto"
df = pd.read_excel('data (1).xlsx')
x = np.array(df['biceps circumference (cm)'])
ax1 = sns.histplot(data=df, x="biceps circumference (cm)", bins=bins)
CodePudding user response:
df = pd.read_excel('data (1).xlsx')
x = np.array(df['biceps circumference (cm)'])
ax1 = sns.displot(x="biceps circumference (cm)", data=df, height=7, aspect=1.6, bins=20, Kind = hist)```