如何将 Plotly express 上的团队名称(x 轴)旋转 90°?他们没有以正确的方式转向。
这是我的代码。
fig = px.bar(stacked_ratio, y="percent", x="team", color="outcome",
color_discrete_map=colors, title="Long-Form Input")
fig.show()
如何将 Plotly express 上的团队名称(x 轴)旋转 90°?他们没有以正确的方式转向。
这是我的代码。
fig = px.bar(stacked_ratio, y="percent", x="team", color="outcome",
color_discrete_map=colors, title="Long-Form Input")
fig.show()
您应该能够使用 update_xaxes
方法从图形对象更新您的 x 轴:
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()
您可以在 plotly 网站上查看 fig.update_xaxes
的所有选项: https://plotly.com/python/reference/layout/xaxis/
嗨,在另一个论坛中找到了这件代码,对我有用。希望这可以帮助!