python - matplotlib: looping though data to produce multiple plots -


i'm trying loop through data , code:

fig = plt.figure(figsize=(8, 6), dpi=120) ax = fig.add_subplot(111) e_key_list = [0.14, 0.23, 0.41, 0.77, 1.26,  1.3, 1.7, 2.2, 3.0, 4.1, 5.8] e_width_ls = [0.09, 0.18, 0.36, 0.49, 66.74, 0.4, 0.5, 0.8, 1.1, 1.7, 7.0]  d in range(7):     in range(len(tme[0])):         bin_data = []         if == 4:             continue         #print         j in range(len(e_eng[i+1])):             if 4.2 <= x[j] <= 5 , int(day[0])+d == int(day[j]):                 bin_data.append(e_eng[i+1][j] - e_bc[i+1][j])          bin_data = np.array(bin_data)         ax.bar(e_key_list[i], np.mean(bin_data), color ='g', width = e_width_ls[i], edgecolor = 'k', align ='edge')     plt.show() 

i want each iteration of d (which meant represent day) produce plot, plot d = 0. on other hand, if plt.show() isn't included, 7 plots want create displayed on same histogram. appreciated!

as understand, want have 7 figures, each 1 barplot. create figure, use plt.figure. however, instead of creating 1 figure, want 7 figures. hence put figure creation loop.

import matplotlib.pyplot plt import numpy np   e_key_list = [0.14, 0.23, 0.41, 0.77, 1.26,  1.3, 1.7, 2.2, 3.0, 4.1, 5.8] e_width_ls = [0.09, 0.18, 0.36, 0.49, 66.74, 0.4, 0.5, 0.8, 1.1, 1.7, 7.0]  d in range(7):     fig = plt.figure(figsize=(8, 6), dpi=120)     ax = fig.add_subplot(111)     in range(5):         bin_data = []         if == 4:             continue         #print         j in range(5):             bin_data.append(j)          bin_data = np.array(bin_data)         ax.bar(e_key_list[i], np.mean(bin_data), color ='g', width = e_width_ls[i], edgecolor = 'k', align ='edge') plt.show() 

if put plt.show() outside loop above 7 figures shown @ once.


Comments

Popular posts from this blog

PHP and MySQL WP -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

go - golang pprof for c library code -