By default the seaborn displaces the X axis ranges from -5 to 35 in distplots. But I need to display the distplots with the X axis ranges from 1 to 30 with 1 unit. How can I do that?
For the most flexible control with these kind of plots, create your own axes object then add the seaborn plots to it. Then you can perform the standard matplotlib changes to features like the x-axis, or use any of the normal controls available through the matplotlib API.
import matplotlib.pyplot as plt
import seaborn as sns
data = [5,8,12,18,19,19.9,20.1,21,24,28]
fig, ax = plt.subplots()
sns.distplot(data, ax=ax)
ax.set_xlim(1,31)
ax.set_xticks(range(1,32))
plt.show()
With the ax
and fig
object exposed, you can edit the charts to your heart's content now, and easily do stuff like changing the size with fig.set_size_inches(10,8))
!