gpt4 book ai didi

seaborn - 为 seaborn FacetGrid distplots 添加均值和可变性

转载 作者:行者123 更新时间:2023-12-02 01:21:22 26 4
gpt4 key购买 nike

向 seaborn FacetGrid 中的每个直方图添加表示平均值(或其他集中趋势度量)的点和可变性度量(例如,标准偏差或置信区间)的最佳方法是什么?

结果应该类似于显示的图 here ,但在每个 FacetGrid 子图中都有一个均值/标准差。 This是非 FacetGrid 案例的相关问题。

最佳答案

根据@mwaskom 的评论,这是一种可能的解决方案(使用 boxplot,类似于 pointplot):

tips = sns.load_dataset("tips")

sns.set(font_scale=1.3)

def dist_boxplot(x, **kwargs):
ax = sns.distplot(x, hist_kws=dict(alpha=0.2))
ax2 = ax.twinx()
sns.boxplot(x=x, ax=ax2)
ax2.set(ylim=(-5, 5))

g = sns.FacetGrid(tips, col="sex")
g.map(dist_boxplot, "total_bill");

"distplot plus boxplot"

(不知道为什么 0.01 稍微向右移动......)

关于seaborn - 为 seaborn FacetGrid distplots 添加均值和可变性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40075915/

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