python - 如何在我的 Seaborn displot y 轴上显示百分比而不是计数?
问题描述
我有以下代码:
sns.displot(data_df_cleaned, x='estimate_error', bins = [-30, -5, 5, 30, 80])
它绘制了以下简单的直方图,但我希望我的y 轴报告百分比。使用 Seaborn 执行此操作很重要,对此我在文档或 stackoverflow 中找不到任何答案。
解决方案
sns.Displot
采用kind='hist'
默认值,如果sns.histplot
调用的参数stat
设置为stat='probability'
,则 y 轴显示百分比而不是计数。所以答案是:
sns.displot(data_df_cleaned, x='estimate_error', bins = [-30, -5, 5, 30, 80], stat='probability')
推荐阅读
- regex - 正则表达式有效,但不适用于 Windows 上 bash 中的 egrep
- c# - 如何重构在字典中存储大量 SqlCommand 的大型类
- javascript - 在 Typescript 中,如何在存储然后从数组访问所述对象时维护对象类型?
- angular - Angular - 一次保存成两(2)个模型
- asp.net-core - Dotnet 监听 ASP.net 的 HTTPS 端口(端口 = 5001)
- angular - Angular 7 路由器:如果路由数据中未提供默认标题,则使用默认标题
- python - Python:循环中的向量化矩阵乘法?
- matlab - 如何在直方图中找到最高峰的 x 值?
- java - java.lang.IllegalStateException android.support.v4.media.session.MediaButtonReceiver.onReceive
- gradle - 使用 TeaVM 编译时出现 IllegalArgumentException