I want to plot a distplot using seaborn with xticks at the mid point of the bins. I am using the below code:
sns.distplot(df['MILEAGE'], kde=False, bins=20)

To get the midpoints of the bars, you can extract the generated rectangle patches and add half their width to their x position. Setting these midpoints as xticks will label the bars.
import matplotlib.pyplot as plt
import seaborn as sns
import numpy as np
ax = sns.distplot(np.random.randn(1000).cumsum(), kde=False, bins=20)
mids = [rect.get_x() + rect.get_width() / 2 for rect in ax.patches]
ax.set_xticks(mids)
plt.show()

If the tick labels would overlap too much, you could rotate them and/or adapt their fontsize:
ax.tick_params(axis='x', rotation=90, labelsize=8)
If you need the bin edges instead of their centers:
edges = [rect.get_x() for rect in ax.patches] + [ax.patches[-1].get_x() + ax.patches[-1].get_width()]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With