How to rotate xtick label bar chart plotly express?
Question:
Answers:
You should be able to update your x-axis from a figure object with the update_xaxes
method:
fig = px.bar(stacked_ratio, y="percent", x="team", color="outcome",
color_discrete_map=colors, title="Long-Form Input")
fig.update_xaxes(tickangle=90)
fig.show()
You can see all options for fig.update_xaxes
on the plotly website here: https://plotly.com/python/reference/layout/xaxis/
Hi found this piece of code in another forum, it worked for me. Hope this helps!
fig.update_xaxes(tickangle= -90)
fig.show()
Tickangle=90
means that the labels will be rotated by 90° clockwise. If you use the negative sign, you rotate the labels by 90° anti-clockwise, so just the other direction.
You should be able to update your x-axis from a figure object with the update_xaxes
method:
fig = px.bar(stacked_ratio, y="percent", x="team", color="outcome",
color_discrete_map=colors, title="Long-Form Input")
fig.update_xaxes(tickangle=90)
fig.show()
You can see all options for fig.update_xaxes
on the plotly website here: https://plotly.com/python/reference/layout/xaxis/
Hi found this piece of code in another forum, it worked for me. Hope this helps!
fig.update_xaxes(tickangle= -90)
fig.show()
Tickangle=90
means that the labels will be rotated by 90° clockwise. If you use the negative sign, you rotate the labels by 90° anti-clockwise, so just the other direction.