0
votes

Sorry for giving an image however I think it is the best way to show my problem.enter image description here

As you can see all of the bin width are different, from my understanding it shows range of rent_hours. I am not sure why different figure have different bin width even though I didn't set any.

My code looks is as follows:

figure, axes = plt.subplots(nrows=4, ncols=3)
figure.set_size_inches(18,14)
plt.subplots_adjust(hspace=0.5)

for ax, age_g in zip(axes.ravel(), age_cat):
    group = total_usage_df.loc[(total_usage_df.age_group == age_g) & (total_usage_df.day_of_week <= 4)]
    sns.distplot(group.rent_hour, ax=ax, kde=False)
    ax.set(title=age_g)
    ax.set_xlim([0, 24])

figure.suptitle("Weekday usage pattern", size=25);

additional question:

Seaborn : How to get the count in y axis for distplot using PairGrid for here it says that kde=False makes y-axis count however http://seaborn.pydata.org/generated/seaborn.distplot.html in the doc, it uses kde=False and still seems to show something else. How can I set y-axis to show count?

I've tried sns.distplot(group.rent_hour, ax=ax, norm_hist=True) and it still seems to give something else rather than count.

sns.distplot(group.rent_hour, ax=ax, kde=False) gives me count however I don't know why it is giving me count.

1

1 Answers

1
votes

Answer 1:

From the documentation:

norm_hist : bool, optional

If True, the histogram height shows a density rather than a count. This is implied if a KDE or fitted density is plotted.

So you need to take into account your bin width as well, i.e. compute the area under the curve and not just the sum of the bin heights.

Answer 2:

# Plotting hist without kde
ax = sns.distplot(your_data, kde=False)

# Creating another Y axis
second_ax = ax.twinx()

#Plotting kde without hist on the second Y axis
sns.distplot(your_data, ax=second_ax, kde=True, hist=False)

#Removing Y ticks from the second axis
second_ax.set_yticks([])