Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- smdt = {'OSS': (24, 26, 24, 30, 30, 30, 29, 29, 32, 31, 34, 33, 36, 34), 'GVS': (41, 45, 37, 60, 46, 46, 41, 33, 43, 40, 46, 48, 54, 48), 'ATS': (99, 97, 0, 93, 82, 97, 99, 100, 100, 99, 100, 100, 100, 0), 'POSS': (42, 41, 38, 46, 46, 34, 28, 28, 58, 58, 69, 67, 71, 83), 'TS': (72, 80, 35, 77, 62, 60, 60, 49, 72, 72, 76, 70, 82, 77), 'RS': (27, 30, 32, 33, 29, 29, 25, 25, 26, 25, 29, 33, 38, 34)}
- params = {
- 'font.size' : 12,
- 'font.family' : 'Calibri',
- 'text.color':'dimgrey',
- 'xtick.color':'dimgrey',
- 'xtick.labelsize':12,
- 'ytick.labelsize':12,
- 'ytick.color':'dimgrey',
- 'lines.linewidth':0.5,
- 'legend.fontsize':10,
- 'axes.labelcolor':'dimgray'
- }
- plt.rcParams.update(params)
- fig = plt.figure() # Create matplotlib figure
- ax = fig.add_subplot(111) # Create matplotlib axes
- fig.set_size_inches(8, 3.5)
- ind = np.arange(14)
- width = 0.16 #18
- width1 = 0.10
- avg_bar1 = smdt['OSS'] # (10,20,30,60)
- avg_bar2 = smdt['ATS'] #(20,26,31,31)
- avg_bar3 = smdt['POSS'] #(30,38,38,39)
- avg_bar4 = smdt['TS'] #(40,25,25,28)
- avg_bar5 = smdt['RS']#(40,55,35,45)
- avg_bar6 = smdt['GVS']
- print ind - 2*width
- rects1 = plt.bar(ind - 2*width, avg_bar1, width=width1, color='#367588',label='bar1', align = 'center')
- rects2 = plt.bar(ind - 1*width, avg_bar2, width=width1, color='#FFBB00', label='bar2', align = 'center')
- rects3 = plt.bar(ind + 0*width, avg_bar3, width=width1, color='#b2b2b2', label='bar3', align = 'center')
- rects4 = plt.bar(ind + 1*width, avg_bar4, width=width1, color='#f87b02', label='bar4', align = 'center')
- rects5 = plt.bar(ind + 2*width, avg_bar5, width=width1, color='#2f86ff', label='bar5', align = 'center')
- high_point_x = []
- high_point_y = []
- for i in range(0,13):
- single_bar_group={rects1[i].get_height():rects1[i].get_x() + rects1[i].get_width()/2.0,
- rects2[i].get_height():rects2[i].get_x() + rects2[i].get_width()/2.0,
- rects3[i].get_height():rects3[i].get_x() + rects3[i].get_width()/2.0,
- rects4[i].get_height():rects4[i].get_x()+rects4[i].get_width()/2.0,
- rects5[i].get_height():rects5[i].get_x() +rects5[i].get_width()/2.0}
- height_list = list(single_bar_group.keys())
- height_list.sort(reverse=True)
- total=int(rects1[i].get_height())+int(rects2[i].get_height())+int(rects3[i].get_height())+int(rects4[i].get_height())+ int( rects5[i].get_height())
- for single_height in height_list:
- high_point_y.append(total/5)
- all_heights = single_bar_group.keys()
- med = np.median(all_heights)
- numb = find_nearest(all_heights, med)
- high_point_x.append(single_bar_group[numb])
- break
- ax.spines['right'].set_visible(False)
- ax.spines['left'].set_visible(False)
- ax.spines['top'].set_visible(False)
- ax.spines['bottom'].set_visible(False)
- remove_tick_param(ax)
- plt.xlim(-0.55,len(cat))
- ax.tick_params(axis='both', which='both', length=0)
- format_per(ax, 'yaxis', '%')
- ax2 = ax.twinx()
- # trend_line =ax2.plot(high_point_x,smdt['Glance Views Share'],color='#7cb85e',label='Glance View',linewidth=2)
- #print ind
- plt.xticks(ind, cat)
- ax2.spines['right'].set_visible(False)
- ax2.spines['left'].set_visible(False)
- ax2.spines['top'].set_visible(False)
- ax2.spines['bottom'].set_visible(False)
- remove_tick_param(ax2)
- ax2.set_xticklabels([]) # turn off x ticks
- format_per(ax2, 'yaxis', '%')
- lst =cat #('Q1 2017', 'Q2 2017', 'Q3 2017', 'Q4 2017')
- colLabels = sorted(lst)
- fig.subplots_adjust(bottom=0.17) # making some room for the table
- cell_text = []
- colors = [["#4285F4","w","w","w" ,"w"],[ "#FFBB00","w","w","w","w" ], ["#b2b2b2","w","w","w" ,"w"], ["#f87b02","w","w","w" ,"w"], ["#2f86ff","w","w","w","w"],["#7cb85e","w","w","w","w"] ]
- cell_text.append(list(avg_bar1))
- cell_text.append(list(avg_bar2))
- cell_text.append(list(avg_bar3))
- cell_text.append(list(avg_bar4))
- cell_text.append(list(avg_bar5))
- cell_text.append(list(avg_bar6))
- rows = ['%s' % x for x in ('OSS', 'ATS', 'POSS','TS','RS', 'GVS')]
- #plt.legend( loc="lower center",bbox_to_anchor=[0.5, -0.1],
- # bbox_transform=fig.transFigure, ncol=3)
- the_table = ax.table(cellText=cell_text, colLabels=colLabels,
- rowLabels=rows,cellLoc='center')#, bbox=[0, -0.27, 1,
- # the_table._cells[(1, -1 )].set_facecolor('#4285F4')
- the_table._cells[(1, -1 )].set_width(0.1) #_text.set_color('#4285F4')
- # for x in the_table._cells:
- # the_table._cells[x].set_width(0.1)
- the_table.add_cell(1,-2, 0.1,0.065).set_facecolor('#367588')
- the_table.add_cell(2,-2, 0.1,0.065).set_facecolor('#FFBB00')
- the_table.add_cell(3,-2, 0.1,0.065).set_facecolor('#b2b2b2')
- the_table.add_cell(4,-2, 0.1,0.065).set_facecolor('#f87b02')
- the_table.add_cell(5,-2, 0.1,0.065).set_facecolor('#2f86ff')
- the_table.add_cell(6,-2, 0.1,0.065).set_facecolor('#7cb85e')
- for cell in the_table._cells:
- the_table._cells[cell].set_linewidth(0.5)
- img_path = str(str('eleventh')+str(uuid)+str(slide_id)+'.png')
- plt.savefig(img_path, bbox_inches="tight", pad_inches=0
Add Comment
Please, Sign In to add comment