I am trying to show the text on the bars based on some filtered data but the text shows the same value for the last item in the list. I can't seem to find out what the issue is because display_texts
itself gives me what I expect
filtered_data = df[df["Year"] == 2017]
display_texts = filtered_data["column_name"].tolist()
fig = px.bar(
filtered_data,
x="x_column",
y="y_column",
color="color",
title="some title",
)
fig.update_traces(
texttemplate=display_texts,
textposition="outside",
)
fig.update_layout(showlegend=False)
fig.update_layout(autosize=False, width=1800, height=600)
CodePudding user response:
You should remove texttemplate=display_texts
and add text=display_texts
to px.bar
.