Text is cut-off in Plotly horizontal bar chart

I created horizontal bar chart in Plotly-dash, but bar text size doesn’t fit to the figure size, so part of the text is cut (please see red-framed area on the screenshot attached).

I tried the following:

  1. Changing left and right margin in figure layout. The whole figure is moving, but the text remains cut.
  2. Setting ‘offset’ in figure data. I’ve got vertical offset of bars, but not horizontal offset of the figure area.

dash bar chart

Then I tried to add option cliponaxis = False. Text become visible, but overlaps axis labels, still not expected behaviour:
dash bar chart2

I will highly appreciate if somebody could advice how to fix it.

You could manually set the xaxis range to avoid this:

fig = fig.update_layout(
    xaxis_range=[-1.0e5, 1.3e5]
)
1 Like

Thank you, it was very helpful!

Now my dashboard looks much better. Hope it will help not only me.

Finally I used the following expression to fit xaxis range:

xaxis = dict(range=[-abs(min(map(float, x2_data))*2 - max(map(float, x2_data))*0.25), max(map(float, x2_data))]),

dash bar chart_solution