gpt4 book ai didi

python - 条形图绘制总和,而不是列的平均值

转载 作者:太空狗 更新时间:2023-10-30 02:28:35 25 4
gpt4 key购买 nike

我是 seaborn plot 的初学者。作为示例,seaborn 提供了一个带有平均“天数”的条形图。但是,是否可以提供一个条形图,其中包含总计(总和)、计数、天数值?

import seaborn as sns 
sns.set_style("whitegrid")
tips = sns.load_dataset("tips")
ax = sns.barplot(x = "day",y = "total_bill",data=tips)

最佳答案

来自文档字符串:

Parameters:
-----------
[...]
estimator : callable that maps vector -> scalar, optional
Statistical function to estimate within each categorical bin.

所以

ax = sns.barplot(x="day", y="total_bill", data=tips, estimator=sum)

enter image description here

关于python - 条形图绘制总和,而不是列的平均值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36271162/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com