creating barplots using for loop using pandas/matplotlib

Viewed 9086

I have below code:

def OS_Usage_Zone_Wise(data,zone): 
   data_os = data['os'].value_counts().plot("bar",figsize=(12,4),fontsize=10)
   data_os.set_title("OS usage in "+zone+" region",color='g',fontsize=20)
   data_os.set_xlabel("OS name",color='b',fontsize=20)
   data_os.set_ylabel("use count",color='b',fontsize=20)


zone = ["east","west","south","central"] 
i = 0
data_os = [data_east,data_west,data_south,data_central] 
for data in data_os:
     OS_Usage_Zone_Wise(data,zone[i])
     print("now "+zone[i])
     i = i+1

I am trying plot for every zone using a for loop,but its displaying oly graph

for 'central' zone,I understand thats it showing the last bar and not displaying

the previous ones,is there any way to plot graph for all zones using a loop(dont

want to do generate graph by using same code again and again)

1 Answers
Related