天天看點

python distplot 圖_seaborn執行個體-distplot-直方圖

好了,這次來看看seaborn中的直方圖

seaborn.distplot

seaborn.distplot(a, bins=None, hist=True, kde=True, rug=False, fit=None, hist_kws=None, kde_kws=None, rug_kws=None, fit_kws=None, color=None, vertical=False, norm_hist=False, axlabel=None, label=None, ax=None)

Flexibly plot a univariate distribution of observations.

關于頻率分布直方圖,我一開始沒搞懂縱坐标是啥,可以參考:

小栗子

主要的,就是我們要傳入一個觀測資料

python distplot 圖_seaborn執行個體-distplot-直方圖

data = np.random.randint(10,100,100)

sns.distplot(data)

python distplot 圖_seaborn執行個體-distplot-直方圖

好了,我們來看一下這個圖

因為我們隻傳入了觀測資料,是以是自動分組的

這個seaborn也有個問題,就是我無法獲得它分的組,如果是使用matplotlib的話,是可以傳回的

按道理說這個圖形的面積應該是1,

為了簡單,我們來指定下分組數,我們就分成1組,哈哈哈

sns.distplot(data , bins=1)

python distplot 圖_seaborn執行個體-distplot-直方圖

然後,我們計算下其他名額,組距的話,就是最大值-最小值

data.max()-data.min()

python distplot 圖_seaborn執行個體-distplot-直方圖

頻率就是1,是以,縱坐标是1/87,差不多是

python distplot 圖_seaborn執行個體-distplot-直方圖

就是這個圖的嘛,恩不錯

其他的幾個參數,可以試試,暫時就看了官方的介紹,後面應用在補充吧