Pandas The plot, how to control the width and spaces

Hope this is a simple question - how to control bandwidth and spaces when building with Pandas?

Full code here , revised below:

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

The width of the resulting string is too thin and the gaps are too wide, how can I fix it? Thank you

+5
source share
1 answer

You can set the width columns:

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

The result is as follows:

enter image description here

Make them thinner:

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

enter image description here

+12
source

Source: https://habr.com/ru/post/1237954/


All Articles