You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何旋转Plotly平行坐标图的轴标签?

旋转Plotly平行坐标图的轴标签

要实现轴标签旋转的效果,你可以通过修改图表布局中parallelcoords的labelangle参数完成,该参数支持设置标签的旋转角度(取值范围-180到180,正数代表逆时针旋转,负数代表顺时针旋转)。

修改后的完整代码如下:

import plotly.express as px
df = px.data.iris()
fig = px.parallel_coordinates(df, color="species_id",
                              dimensions=['sepal_width', 'sepal_length', 'petal_width',
                                          'petal_length'],
                              color_continuous_scale=px.colors.diverging.Tealrose,
                              color_continuous_midpoint=2)
# 设置轴标签垂直旋转(90度逆时针)
fig.update_layout(parallelcoords_labelangle=90)
fig.show()

如果需要其他旋转角度,比如逆时针旋转45度,直接将labelangle的值改为45即可;若想顺时针旋转,设置为负数(如-45)即可调整方向。

内容的提问来源于stack exchange,提问作者Hyunseung Kim

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.22 16:24:29