網站首頁 編程語言 正文
一、直方圖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) # 設定隨機數種子
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'}) # 設置數據頻率分布顏色
plt.show()
函數及參數介紹:
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 數據源
- bins 箱數hist、kde、rug 是否顯示箱數、密度曲線、數據分布,默認顯示箱數和密度曲線不顯示數據分析
- {hist,kde,rug}_kws 通過字典形式設置箱數、密度曲線、數據分布的各個特征
- norm_hist 直方圖的高度是否顯示密度,默認顯示計數,如果kde設置為True高度也會顯示為密度
- color 顏色
- vertical 是否在y軸上顯示圖標,默認為False即在x軸顯示,即豎直顯示
- axlabel 坐標軸標簽
- label 直方圖標簽
二、密度圖
2.1 單個樣本數據分布密度圖
原文鏈接:https://blog.csdn.net/weixin_46713695/article/details/125773614
相關推薦
- 2022-06-16 python讀取txt數據的操作步驟_python
- 2022-10-13 C++智能指針詳解_C 語言
- 2022-11-30 C++之值傳遞&指針傳遞&引用傳遞的示例詳解_C 語言
- 2022-03-14 window環境編譯在linux環境運行的golang程序
- 2022-08-21 Android使用貝塞爾曲線畫心形_Android
- 2022-09-13 C/C++合并兩個升序鏈表的方式_C 語言
- 2023-12-25 前后端驗證碼分析(字母&計算)
- 2022-09-17 Python中re.findall()用法詳解_python
- 最近更新
-
- window11 系統安裝 yarn
- 超詳細win安裝深度學習環境2025年最新版(
- Linux 中運行的top命令 怎么退出?
- MySQL 中decimal 的用法? 存儲小
- get 、set 、toString 方法的使
- @Resource和 @Autowired注解
- Java基礎操作-- 運算符,流程控制 Flo
- 1. Int 和Integer 的區別,Jav
- spring @retryable不生效的一種
- Spring Security之認證信息的處理
- Spring Security之認證過濾器
- Spring Security概述快速入門
- Spring Security之配置體系
- 【SpringBoot】SpringCache
- Spring Security之基于方法配置權
- redisson分布式鎖中waittime的設
- maven:解決release錯誤:Artif
- restTemplate使用總結
- Spring Security之安全異常處理
- MybatisPlus優雅實現加密?
- Spring ioc容器與Bean的生命周期。
- 【探索SpringCloud】服務發現-Nac
- Spring Security之基于HttpR
- Redis 底層數據結構-簡單動態字符串(SD
- arthas操作spring被代理目標對象命令
- Spring中的單例模式應用詳解
- 聊聊消息隊列,發送消息的4種方式
- bootspring第三方資源配置管理
- GIT同步修改后的遠程分支