擅长:python、mysql、java
<p>您可以在<code>sns.barplot</code><code>estimator</code>中使用自己的函数,如<a href="https://stanford.edu/~mwaskom/software/seaborn/generated/seaborn.barplot.html" rel="nofollow noreferrer">docs</a>:</p>
<blockquote>
<p><strong>estimator</strong> : callable that maps vector -> scalar, optional<br/>
Statistical function to estimate within each categorical bin.</p>
</blockquote>
<p>对于您的情况,可以将函数定义为lambda:</p>
<pre><code>sns.barplot(x='group', y='Values', data=df, estimator=lambda x: sum(x==0)*100.0/len(x))
</code></pre>
<p><a href="https://i.stack.imgur.com/vt8o4.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/vt8o4.png" alt="enter image description here"/></a></p>