Set offset of text_auto in barplots

How to shift the text_auto labels of barplots, so that they don’t collide with error bars? Either to side or up or down.

import plotly.express as px
px.bar((1,2,3,), text_auto=".4s", error_y=[0.2, 0.2, 0.2])

Hi @Madrigallo ,

as far as I know if you use text_auto, it will be very limited to customize that.

And if you care about another ideas of customizing text label’s position inside the bar plot, this is what I thought.
Instead using text_auto, it will be more flexible to shift the text to right side of error bar using text.
By adding right amount of space before the text using   html entity on each element of text in the list.
You can do loops inside list using list comprehension.

import plotly.express as px
y = (1,2,3)
# fig= px.bar(y, text_auto=".4f", error_y=[0.2, 0.2, 0.2])
fig= px.bar(y, text=[(' '*12)+f'{label:.4f}' for label in y], error_y=[0.2, 0.2, 0.2])
fig.show()

The second alternative is using text annotations.

Hope this reply help you find solution.