Iām generating a grouped bar chart and have text displaying within the bars. I figured out how to add annotations directly above each bar group (for each category on the x axis). However currently the annotation is displaying above the bar relative to the whole bar group - not the individual bars. As you can see I have 5 bars. How can I get the x position of each individual bar so that I can put the annotation in the right position?
I have a screenshot here to illustrate this.
This is the code that I have so far:
#configure the layout
layout = go.Layout(
title=chart_title,
annotations=[
dict(
x=xpos,
y=float(ypos.strip('%')),
xref='x',
yref='y',
text=str(count),
showarrow=True,
arrowhead=1
) for xpos, ypos, count in zip(dates, percents_by_category, counts_list)
],
yaxis=dict(
title="My Title",
ticksuffix="%"),
xaxis=dict(
title="Date"),
barmode='group',
plot_bgcolor='rgb(233,233,233)')
fig = go.Figure(data=traces, layout=layout)
plot(fig, filename='grouped-bar-chart')