Can someone help me rewrite this code (fig with multiple histograms) with a for loop or function?
Can someone help me rewrite this code (fig with multiple histograms) with a for loop or function? I looked at a similar post but am still struggling with it. You don't have to write out the whole code if you don't want. But a syntactical guide would be helpful. Here is my lengthy manual approach: # Grid of MMR distributions by every 5 years mmr_1990 = mmr[mmr['Year']=='1990'] mmr_1995 = mmr[mmr['Year']=='1995'] mmr_2000 = mmr[mmr['Year']=='2000'] mmr_2005 = mmr[mmr['Year']=='2005'] mmr_2010 = mmr[mmr['Year']=='2010'] mmr_2015 = mmr[mmr['Year']=='2015'] year_list = [mmr_1990, mmr_1995, mmr_2000, mmr_2005, mmr_2010, mmr_2015] fig = plt.figure(figsize=(12,8)) ax1 = fig.add_subplot(2,3,1) ax2 = fig.add_subplot(2,3,2) ax3 = fig.add_subplot(2,3,3) ax4 = fig.add_subplot(2,3,4) ax5 = fig.add_subplot(2,3,5) ax6 = fig.add_subplot(2,3,6) #1990 ax1.hist(mmr_1990['MMR'], color='dar...