python - 如何旋转 xtick 标签条形图 plotly express?
问题描述
如何将 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()
您可以fig.update_xaxes
在此处查看 plotly 网站上的所有选项:https ://plotly.com/python/reference/layout/xaxis/
推荐阅读
- c# - 当自动滚动更改为 false 时,是什么导致滚动条变为 0
- python - 如何将项目推送到数组并在 MongoDB 中获取该项目的索引,find_one_and_update pymongo 中的投影
- tensorflow - 将不同形状的特征矩阵组合成一个特征
- linux - 获取单个进程的平均 CPU 使用百分比,直到我在 bash 脚本中将其杀死
- html - R闪亮仪表板中带有HTML锚的侧边栏菜单
- java - 无法使用 android.support.v7.widget.Toolbar
- ios - Collectionview 第二项从中心而不是顶部开始
- ssh - ImageMagick 通过 SSH 安装错误“./configure.lineno: line 480: expr: command not found”
- python-3.x - 如何在数据框中将行拆分为列
- amazon-web-services - AWS:忽略策略条件语句