seaborn分布圖---單分布(直方圖distplot、核函數密度估計圖kdeplot)、雙分布(雙變量關系圖jointplot、變量關系組圖pairplot、將數組中的數據點繪制為軸上的數據rugplot)


分布圖包括單變量核密度曲線,直方圖,雙變量多變量的聯合直方圖,和密度圖

1.單分布

(1)直方圖distpot

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)
  • seaborn.distplot

  • 設置 kde=False 則可以只繪制直方圖,或者 hist=False 只繪制核密度估計圖

舉例:

sns.distplot(iris["sepal_length"])

(2)核函數密度估計圖kdeplot

seaborn.kdeplot(data, data2=None, shade=False, vertical=False, kernel='gau', bw='scott', gridsize=100, cut=3, clip=None, legend=True, cumulative=False, shade_lowest=True, cbar=False, cbar_ax=None, cbar_kws=None, ax=None, **kwargs)
  • kdeplot 可以專門用於繪制核密度估計圖,其效果和 distplot(hist=False) 一致,但 kdeplot 擁有更多的自定義設置
  • seaborn.kdeplot

舉例:

sns.kdeplot(iris["sepal_length"])

2.雙分布

(1)二元變量分布圖jointplot

seaborn.jointplot(x, y, data=None, kind='scatter', stat_func=None, color=None, height=6, ratio=5, space=0.2, dropna=True, xlim=None, ylim=None, joint_kws=None, marginal_kws=None, annot_kws=None, **kwargs)
  • seaborn.jointplot

  • jointplot 並不是一個 Figure-level 接口,但其支持 kind= 參數指定繪制出不同樣式的分布圖。例如,繪制出核密度估計對比圖 kind = 'kde'。
  • kind='hex'繪制六邊形計數圖
  • kind='reg'繪制回歸擬合圖

舉例:

例如,我們探尋 sepal_length 和 sepal_width 二元特征變量之間的關系。

sns.jointplot(x="sepal_length", y="sepal_width", data=iris)  

(2)變量關系組圖pairpot

支持將數據集中的特征變量兩兩對比繪圖,默認情況下,對角線上是單變量分布圖,而其他是二元變量分布圖

seaborn.pairplot(data, hue=None, hue_order=None, palette=None, vars=None, x_vars=None, y_vars=None, kind='scatter', diag_kind='auto', markers=None, height=2.5, aspect=1, dropna=True, plot_kws=None, diag_kws=None, grid_kws=None, size=None)

舉例:

sns.pairplot(iris, hue="species")

(3)將數組中的數據點繪制為軸上的數據rugplot

seaborn.rugplot(a, height=0.05, axis='x', ax=None, **kwargs)

  


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM