1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
|
color_palette = ['black', (193/255, 1/255, 1/255), 'w', (127/255, 126/255, 127/255), 'blue'] pattern_list = ["", "/", "+", "\\", "x"] edgecolor_list = ['w', 'w', (0/255, 176/255, 80/255), 'w', 'w'] ax.bar(x + offset, measurement, width, label=species_name, color=color_palette[idx], hatch = pattern_list[idx], edgecolor=edgecolor_list[idx], linewidth=1, ) ax.bar(x + offset, measurement, width, label=species_name, color = "none", edgecolor='black', linewidth=1, )
handles1, labels1 = ax.get_legend_handles_labels() plt.legend([handles1[2*idx]+handles1[2*idx+1] for idx in range(group_count)], [labels1[2*idx] for idx in range(group_count)], loc='upper center', bbox_to_anchor=(0.5, 1.12), ncol=group_count, frameon=False, columnspacing=legend_width, handleheight=1.2, prop={'size': graph_data.fontsize, 'weight': 'heavy'} )
overflow_pattern = ["/" if y > maxY else "" for y in entry[1]] fig.add_bar(x=x,y=yList, name=barName, marker=dict( color=color_list[i], pattern_shape = overflow_pattern, line=dict(color='black', width=2) ), textfont=dict(size=graph_data.fontsize), )
legend_num = len( barDict.items()) fig.update_layout(barmode="relative",
legend = dict( entrywidthmode='fraction', entrywidth= 0.2, x=0.5 - 0.5 * legend_num * 0.2, y=1.2, orientation="h", ), )
|