擅长:python、mysql、java
<p>我知道我的答案来得很晚,但我希望有人能从中受益。</p>
<p>为了解决上述问题,我在重新整理数据后使用了下面的代码:</p>
<p>数据:</p>
<pre><code>d = {'class': ['first', 'second', 'third', 'first', 'second', 'third', 'first', 'second', 'third'], 'sex': ['men', 'men', 'men', 'woman', 'woman', 'woman', 'children', 'children', 'children'], 'survival_rate':[0.914680, 0.300120, 0.118990, 0.667971, 0.329380, 0.189747, 0.660562, 0.882608, 0.121259]}
df = pd.DataFrame(data=d)
</code></pre>
<p><a href="https://i.stack.imgur.com/FNjif.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/FNjif.png" alt="enter image description here"/></a></p>
<pre><code>sns.factorplot("sex", "survival_rate", col="class", data=df, kind="bar")
</code></pre>
<p><a href="https://i.stack.imgur.com/IPzSi.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/IPzSi.png" alt="enter image description here"/></a></p>