網站首頁 編程語言 正文
一、直方圖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-10-01 Python函數參數基礎介紹及示例_python
- 2022-09-02 pytest使用@pytest.mark.parametrize()實現參數化的示例代碼_pytho
- 2023-03-13 ViewModel中StateFlow和SharedFlow單元測試使用詳解_Android
- 2021-12-07 Android證書安裝過程介紹_Android
- 2022-07-14 python如何獲取當前系統的日期_python
- 2022-08-04 C#中ListView用法實例_C#教程
- 2022-12-22 Nginx配置之main?events塊使用示例詳解_nginx
- 2022-07-16 借助Redis的過期機制和分布式鎖實現定時任務
- 最近更新
-
- 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同步修改后的遠程分支