Limit the range of x in seaborn distplot KDE estimation
Setting plt.xlim(0, 1)
beforehand should help :
import matplotlib.pyplot as plt
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))