python使用seaborn繪圖直方圖displot,密度圖,散點圖
發(fā)布日期:2022-07-20 19:45 | 文章來源:源碼中國
一、直方圖distplot()
import numpy as np import seaborn as sns import matplotlib.pyplot as plt import matplotlib import pandas as pd fig = plt.figure(figsize=(12, 5)) ax1 = plt.subplot(121) rs = np.random.RandomState(10) # 設定隨機數(shù)種子 s = pd.Series(rs.randn(100) * 100) sns.distplot(s, bins=10, hist=True, kde=True, rug=True, norm_hist=False, color='y', label='distplot', axlabel='x') plt.legend() ax1 = plt.subplot(122) sns.distplot(s, rug=True, hist_kws={"histtype": "step", "linewidth": 1, "alpha": 1, "color": "g"}, # 設置箱子的風格、線寬、透明度、顏色,風格包括:'bar', 'barstacked', 'step', 'stepfilled' kde_kws={"color": "r", "linewidth": 1, "label": "KDE", 'linestyle': '--'},# 設置密度曲線顏色,線寬,標注、線形 rug_kws={'color': 'r'}) # 設置數(shù)據(jù)頻率分布顏色 plt.show()
函數(shù)及參數(shù)介紹:
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)
- a 數(shù)據(jù)源
- bins 箱數(shù)hist、kde、rug 是否顯示箱數(shù)、密度曲線、數(shù)據(jù)分布,默認顯示箱數(shù)和密度曲線不顯示數(shù)據(jù)分析
- {hist,kde,rug}_kws 通過字典形式設置箱數(shù)、密度曲線、數(shù)據(jù)分布的各個特征
- norm_hist 直方圖的高度是否顯示密度,默認顯示計數(shù),如果kde設置為True高度也會顯示為密度
- color 顏色
- vertical 是否在y軸上顯示圖標,默認為False即在x軸顯示,即豎直顯示
- axlabel 坐標軸標簽
- label 直方圖標簽
二、密度圖
2.1 單個樣本數(shù)據(jù)分布密度圖
到此這篇關于python使用seaborn繪圖直方圖displot,密度圖,散點圖的文章就介紹到這了,更多相關python seaborn繪圖 內(nèi)容請搜索本站以前的文章或繼續(xù)瀏覽下面的相關文章希望大家以后多多支持本站!
版權聲明:本站文章來源標注為YINGSOO的內(nèi)容版權均為本站所有,歡迎引用、轉載,請保持原文完整并注明來源及原文鏈接。禁止復制或仿造本網(wǎng)站,禁止在非www.sddonglingsh.com所屬的服務器上建立鏡像,否則將依法追究法律責任。本站部分內(nèi)容來源于網(wǎng)友推薦、互聯(lián)網(wǎng)收集整理而來,僅供學習參考,不代表本站立場,如有內(nèi)容涉嫌侵權,請聯(lián)系alex-e#qq.com處理。
相關文章