2015-12-11 4 views
5

これは簡単な質問です - パンダでプロットする際のバー幅とギャップを制御するにはどうすればいいですか?パンダプロット、バー幅とギャップを制御する方法

Full code is here、以下転載:

df = pd.DataFrame({ 
     'person':[x*3 for x in list('ABCDEF')], 
     'score1':np.random.randn(6), 
     'score2':np.random.randn(6), 
     'score3':np.random.randn(6), 
     'score4':np.random.randn(6), 
     'score5':np.random.randn(6) 
        }) 
print(df) 
ax = df.set_index(['person']).plot(kind='barh') 
ax.invert_yaxis() 

enter image description here

私はそれを修正することができますどのように、結果バーの幅が薄すぎるとのギャップが広すぎますか?ありがとう。

答えて

12

あなたがバーのwidth設定することができます。

ax = df.set_index(['person']).plot(kind='barh', width=1.0) 

結果は次のようになります。

シンナーそれらを再度行います。

ax = df.set_index(['person']).plot(kind='barh', width=0.5) 

enter image description here

関連する問題