擅长:python、mysql、java
<p>使用seaborn和df.melt的另一种方法</p>
<pre><code>import pandas as pd
import seaborn as sns
df = pd.DataFrame(data={'Model':['RNNs','Naive Bayes','Random Forest', 'SVM Classifier'],
'Positive':[99,22,51,40],
'Negative':[1,38,9,20]})
df = df.melt('Model', var_name='cols', value_name='vals')
g = sns.factorplot(x="Model", y="vals", hue='cols', data=df,kind='bar')
g.set_xticklabels(rotation=90)
</code></pre>
<p><a href="https://i.stack.imgur.com/SCBrT.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/SCBrT.png" alt="enter image description here"/></a></p>