python - matplotlib changing barplot xtick labels and sorting the order of bars -


i have dataset i'm trying plot, how plot it:

   in range(0,5):     plt.subplot2grid((1,5),(0,i))     df.survived[df.sibsp == i].value_counts().plot(kind='bar')     title(str(i)) 

the values in x (survived) 0 or 1 , i'm plotting value count of them. i'm trying change xsticks "survived"\"not survived", how can it?

and i'm trying sort xsticks @ graphs @ same way (as can see in pic default sort according ycount, causing x's 0-1 @ first graph , 1-0 @ second graph) enter image description here

i not sure how data looks like, assume 1 means survived , 0 means dead, , there no other values other 0 , 1. if so, need few small changes:

for in range(0,5):     plt.subplot2grid((1,5),(0,i))     ax=df.survived[df.sibsp == i].value_counts().ix[[0,1]].plot(kind='bar')     ax.set_xticklabels(['alive', 'dead'])      title(str(i)) 

and should ready go.


Comments

Popular posts from this blog

database - VFP Grid + SQL server 2008 - grid not showing correctly -

jquery - Set jPicker field to empty value -

.htaccess - htaccess convert request to clean url and add slash at the end of the url -