Limit the range of x in seaborn distplot KDE estimation

后端 未结 2 493
北荒
北荒 2021-02-08 13:01

Suppose we have an array with numbers between 0 and 1:

arr=np.array([ 0.        ,  0.        ,  0.        ,  0.        ,  0.6934264 ,
               0.        ,          


        
2条回答
  •  傲寒
    傲寒 (楼主)
    2021-02-08 13:36

    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))
    

提交回复
热议问题