I am not sure how to put all these graph in tabular format. All of them are showing up one after another.
plt.figure(figsize=(15, 12))
plt.subplots_adjust(hspace=0.5)
for r,x in enumerate(data.county.unique()):
t_dict={}
for c,y in enumerate(col):
if len(data[ (data.county==x) & (data[y]==1)][y].value_counts()) >0 :
ct=data[ (data.county==x) & (data[y]==1)][y].value_counts().item()
t_dict.update({y:ct})
if len(t_dict)>0:
pd.DataFrame([t_dict]).plot.bar(title=x)
#plt.show()
CodePudding user response:
CodePudding user response:
I did this way. seems working.
fig, axs =plt.subplots(8, 5,figsize=(75, 75))
r1=0
c1=0
for r,x in enumerate(data.county.unique()):
t_dict={}
for c,y in enumerate(col):
if len(data[ (data.county==x) & (data[y]==1)][y].value_counts()) >0 :
ct=data[ (data.county==x) & (data[y]==1)][y].value_counts().item()
t_dict.update({y:ct})
if len(t_dict)>0:
pd.DataFrame([t_dict]).plot.bar(title=x,ax=axs[r1][c1])
#plt.tight_layout()
if c1 == 4:
c1=0
r1=r1 1
else:
c1=c1 1
axs[r1][3].remove()
axs[r1][4].remove()