如何在Plotly 3D图中更改轴标签?

5
X = np.random.randn(100, 90)
import plotly.graph_objects as go

fig = go.Figure(data=[go.Surface(z=X)])

fig.update_layout(title='something', autosize=False,
                  width=500, height=500,
                  margin=dict(l=65, r=50, b=65, t=90))

fig.show()

尝试了各种方法,但轴标签没有改变。它们仍然显示为 "x" 和 "y"。
1个回答

13
您可以在场景属性内更改轴标签。
import numpy as np
import plotly.graph_objects as go

X = np.random.randn(100, 90)
import plotly.graph_objects as go

fig = go.Figure(data=[go.Surface(z=X)])

fig.update_layout(
    title='something', 
    autosize=False,
    width=500, 
    height=500,
    margin=dict(l=65, r=50, b=65, t=90),
    scene=dict(
        xaxis_title='X Axis Title',
        yaxis_title='Y Axis Title',
        zaxis_title='Z Axis Title',
    ),
)

fig.show()

enter image description here


太麻烦了。 - huang
注意:3D图形在布局中有一个名为“场景”的属性,其中包含诸如xaxis、yaxis和zaxis参数等属性。https://plotly.com/python/3d-axes/#range-of-axes - masaya

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接