Does Seaborn distplot not support a range?
You could just filter your data and call displot
over the filtered data:
filtered = data1[(data1 >= 0) & (data1 < 10)]
sns.distplot(filtered, kde=True, hist=True, hist_kws={"range": [0,10]})
plt.show()
Assuming data1
is a numpy array.
You can set a range for Axes
object that sns
returns.
ax = sns.distplot(data1, kde=True, hist=True, hist_kws={"range": [0,10]})
ax.set_xlim(0, 10)
If you want the KDE and histogram to be computed only for the values in [0,10] you can use the arguments kde_kws={"clip":(0,10)}, hist_kws={"range":(0,10)}
:
sns.distplot(data1, kde=True, hist=True, kde_kws={"clip":(0,10)}, hist_kws={"range":(0,10)})
plt.show()