So Iām trying to create a bar chart where each bar is stacked and each has a specific color. In order to make the stacked part distinguishable, I tried both with marker_pattern_shape and marker_opacity. Both solutions works fine for the plots, but the legend is less than ideal; with the pattern if the color of the first bar (which is the one the legend will use) is a light color (making the pattern hard to identify); with the opacity since the legend marker does not reflect the difference.
The ideal solution would be if you could customize the color and size of markers in the legend, and/or if opacity was reflected in the markers in the legend.
animals=['seal', 'orangutans', 'monkeys']
animal_colors=['teal', 'orange', 'grey']
fig = go.Figure(data=[
go.Bar(name='SF Zoo', x=animals, y=[20, 14, 23], marker_color=animal_colors),
go.Bar(name='LA Zoo', x=animals, y=[12, 18, 29], marker_color=animal_colors, marker_pattern_shape='/')
])
# Change the bar mode
fig.update_layout(barmode='stack')
fig.show()
animals=['seal', 'orangutans', 'monkeys']
animal_colors=['teal', 'orange', 'grey']
fig = go.Figure(data=[
go.Bar(name='SF Zoo', x=animals, y=[20, 14, 23], marker_color=animal_colors),
go.Bar(name='LA Zoo', x=animals, y=[12, 18, 29], marker_color=animal_colors, marker_opacity=0.8)
])
# Change the bar mode
fig.update_layout(barmode='stack')
fig.show()
Cheers!