I had the same problem and used ChatGPT to solve this:
Wrap tick labels after 15 characters
# Ticklabels wrap
fig.update_layout(xaxis={âtickmodeâ: âarrayâ,
âtickvalsâ: df.index,
âticktextâ: [txt[:15] + â â + txt[15:] if len(txt) > 15 else txt for txt in fig[âlayoutâ][âxaxisâ][âcategoryarrayâ]]})
Wrap tick labels after 15 characters at the next whitespace and set tickangle
# Ticklabels umbruchen
fig.update_layout(xaxis={âtickmodeâ: âarrayâ,
âtickvalsâ: df.index,
âticktextâ: [txt[:15] + â â + txt[15:] if len(txt) > 15 else txt for txt in fig[âlayoutâ][âxaxisâ][âcategoryarrayâ]]})