Suppose we have an array with numbers between 0 and 1:
arr=np.array([ 0. , 0. , 0. , 0. , 0.6934264 ,
0. ,
Settins plt.xlim(0, 1)
beforehand should help :
plt.xlim(0, 1)
sns.distplot(arr, hist=False)
The correct way of doing this, is by using the clip
keyword instead of range
:
sns.distplot(arr, hist=False, kde_kws={'clip': (0.0, 1.0)})
which will produce:
Indeed, if you only care about the kde and not the histogram, you can use the kdeplot
function, which will produce the same result:
sns.kdeplot(arr, clip=(0.0, 1.0))