且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在Python中的分组箱图中显示均值和偏差值

更新时间:2023-12-02 12:11:10

This question brought me here since I was also looking for a similar solution with seaborn.

经过反复试验,您只需将 for循环更改为:

After some trial and error, you just have to change the for loop to:

for i in range(len(m)):
    bp.annotate(
        ' μ={:.2f}\n σ={:.2f}'.format(m[i], st[i]), 
        xy=(i, m[i]), 
        horizontalalignment='center'
    )

此更改对我有用(尽管我只是想打印实际的中值).您也可以添加更改,例如将 fontsize color 或样式(即 weight )添加为 annotate .

This change worked for me (although I just wanted to print the actual median values). You can also add changes like the fontsize, color or style (i.e., weight) just by adding them as arguments in annotate.