def run_plot_wheat(): try: annualWheatDict = get_wheat_data() prodList = [] harvList = [] plntList = [] yearList = [] N = len(annualWheatDict) + 1 print(min(annualWheatDict.keys())) ind = np.arange(1,16,1) width = .3 print(ind) for year in sorted(annualWheatDict.keys()): #prodList.append(annualWheatDict[year][]) yearList.append(str(year)) plntList.append(int(annualWheatDict[year][1]/1000000)) harvList.append(int(annualWheatDict[year][2]/1000000)) fig, ax = plt.subplots() print(len(plntList)) barPlant = ax.barh(ind, plntList, color = 'b', height =width, align = 'center') barHarv = ax.barh(ind + width, harvList, color = 'y', height =width, align = 'center') plt.ylabel('Years') plt.yticks(ind,sorted(yearList)) #ax.set_yticklabels( sorted(yearList)[]) #plt.yticks(np.arange(N+1)) plt.legend((barPlant[0],barHarv[0]),('Planted','Harvested')) #plt.title('Wheat Production') plt.show() #plt.savefig("figure.pdf") except: config.run_error_message("Error in plotting wheat")
def run_plot_dice_rolls(): try: fig, ax = plt.subplots() diceSetDict = dbsql.get_rolls_per_set() bar3v_51 = ax.bar(ind - width, diceSetDict['3v-51'][1], color='y', width=width, align='center') bar3v_26 = ax.bar(ind, diceSetDict['3v-26'][1], color='r', width=width, align='center') bar3v_62 = ax.bar(ind + width, diceSetDict['3v-62'][1], color='b', width=width, align='center') plt.ylabel('Number of Rolls') plt.xticks(xValues) plt.yticks(np.arange(1, 12, 1)) plt.legend((bar3v_51[0], bar3v_26[0], bar3v_62[0]), ('3v-51', '3v-26', '3v-62')) plt.title('Number of rolls per set') plt.show() #plt.savefig("figure.pdf") except: config.run_error_message("Error in plotting dice rolls")
def run_plot_dice_rolls(): try: fig, ax = plt.subplots() diceSetDict = dbsql.get_rolls_per_set() bar3v_51 = ax.bar(ind - width, diceSetDict['3v-51'][1], color = 'y', width =width, align = 'center') bar3v_26 = ax.bar(ind , diceSetDict['3v-26'][1], color = 'r', width =width, align = 'center') bar3v_62 = ax.bar(ind + width, diceSetDict['3v-62'][1], color = 'b', width =width, align = 'center') plt.ylabel('Number of Rolls') plt.xticks(xValues) plt.yticks(np.arange(1,12,1)) plt.legend((bar3v_51[0],bar3v_26[0],bar3v_62[0]),('3v-51','3v-26','3v-62')) plt.title('Number of rolls per set') plt.show() #plt.savefig("figure.pdf") except: config.run_error_message("Error in plotting dice rolls")
def run_plot_wheat(): try: annualWheatDict = get_wheat_data() prodList = [] harvList = [] plntList = [] yearList = [] N = len(annualWheatDict) + 1 print(min(annualWheatDict.keys())) ind = np.arange(1, 16, 1) width = .3 print(ind) for year in sorted(annualWheatDict.keys()): #prodList.append(annualWheatDict[year][]) yearList.append(str(year)) plntList.append(int(annualWheatDict[year][1] / 1000000)) harvList.append(int(annualWheatDict[year][2] / 1000000)) fig, ax = plt.subplots() print(len(plntList)) barPlant = ax.barh(ind, plntList, color='b', height=width, align='center') barHarv = ax.barh(ind + width, harvList, color='y', height=width, align='center') plt.ylabel('Years') plt.yticks(ind, sorted(yearList)) #ax.set_yticklabels( sorted(yearList)[]) #plt.yticks(np.arange(N+1)) plt.legend((barPlant[0], barHarv[0]), ('Planted', 'Harvested')) #plt.title('Wheat Production') plt.show() #plt.savefig("figure.pdf") except: config.run_error_message("Error in plotting wheat")