I currently have a stacked bar chart for brewers. There are 6 brewers. It is good to understand the volume but I want to highlight in my analysis that some of the brewers are being used more than others. To do so I need to turn my bar chart in to 100% stacked bar.
I want it so that each of these bars y-axis is always 100.
The code I have at the moment is:
`def brewer_number_bar(location):
brewer_df_filtered = brewer_df[(brewer_df['Location Name'].isin(location))]
traces = []
for brewer in brewer_df['Menu Item Name'].unique():
brewer_df_by_brewer = brewer_df_filtered[brewer_df_filtered['Menu Item Name']==brewer]
traces.append(go.Bar(
x = brewer_df_by_brewer['Business Date'],
y = brewer_df_by_brewer['Sales Count'],
name=brewer,
))
return {'data': traces,
'layout': go.Layout(title='Brewer Volume',
xaxis={'title': 'Date', 'categoryorder': 'total descending'},
yaxis={'title': 'Brewer Numbers Used'},
barmode='stack')
}`
I have tried to take brewer_df_by_brewer['Sales Count'] / brewer_df_by_brewer['Sales Count'].sum()
and created a new trace for each but as I also have location in there it has not worked.
brewer_df
? you can copy and paste the output from brewer_df.head().to_dict()
into your question