【问题标题】:How to rotate xtick label bar chart plotly express?如何旋转 xtick 标签条形图 plotly express?
【发布时间】:2021-09-24 18:39:08
【问题描述】:

如何将 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()

如下所示:

【问题讨论】:

    标签: python plotly


    【解决方案1】:

    您应该能够使用 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/

    【讨论】:

      猜你喜欢
      • 2020-08-19
      • 1970-01-01
      • 2014-09-05
      • 2017-12-10
      • 1970-01-01
      • 1970-01-01
      • 2021-11-30
      • 1970-01-01
      • 2017-08-30
      相关资源
      最近更新 更多