python - How to plot multiple rows on Pandas? -


say have following pandas dataframe:

in[114]: df out[114]:       0-10%  11-20%  21-30%  31-40%  41-50%  51-60%  61-70%  71-80%  81-90%  \ f    0.186   3.268   3.793   4.554   6.421   6.345   7.383   8.476   8.968    l    1.752   2.205   2.508   2.866   3.132   3.157   3.724   4.073   4.905          91-100%   f     12.447   l      8.522 

and want produce barplot have columns categories on x axis and, each category, 2 bars, 1 f , 1 l, make comparisons.

how in order avoid bars being stacked?

my attempt produces stacked bars , offset in terms of x labels:

x = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] labels = ['0-10%','11-20%','21-30%','31-40%','41-50%','51-60%','61-70%','71-80%','81-90%','91-100%'] row1 = df.iloc[0] row1.plot(kind='bar',title='binned comparison', color='r',stacked=false) row2 = df.iloc[1] row2.plot(kind='bar',title='binned comparison', color='k',stacked=false) plt.xticks(x,labels, rotation='horizontal',fontsize=8) 

you can plot.bar on transpose:

df.t.plot.bar() 

enter image description here


Comments

Popular posts from this blog

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -