使用 Plotly 时如何向 3D 表面图像添加颜色条标题?

问题描述 投票:0回答:1

我一直在尝试使用 Plotly 和 Python3 创建 3D 曲面图。我是根据官方案例来画的,但是案例并没有说明如何给colorbar添加标题

我尝试运行以下命令但没有成功。

fig.update_layout(colorbar=dict(title='Temperature(K)'), titleside='right')

错误显示为: 错误的属性路径: 颜色条 ^^^^^^^^ 另外,有没有办法为颜色条上的值添加单位?

python 3d plotly title surface
1个回答
0
投票

您可以直接在

go.Surface()
构造函数中指定它,例如。 :

fig = go.Figure(data=[go.Surface(z=zdata,
                                 colorbar_title_text='Colorbar Title')])

铌。

colorbar_title_text
使用“魔术下划线”表示法作为
colorbar=dict(title=dict(text='...'))
的快捷方式。

参见https://plotly.com/python/reference/surface/#surface-colorbar-title-text

© www.soinside.com 2019 - 2024. All rights reserved.