无法更改 python 中 plotly 曲面图中的轴标题

Unable to change axis titles in plotly surface plot in python

我正在使用 plotly 版本 3.9.0 和 python 3.7。我正在尝试使用 python 绘制一个简单的曲面图。我已经成功地用预期的配色方案渲染了绘图,但是在更改 X、Y、Z 轴的轴标题以及控制每个轴的刻度频率和刻度标签方面遇到了问题。我在 SO 上尝试了其他相关问题的一些解决方案,但没有取得太大成功。因此,我想 post 下面的代码片段向 SO 社区寻求帮助,了解如何更改轴标签以及设置轴刻度和刻度标签。

import plotly.plotly as py
import plotly.graph_objs as go

data = [
    go.Surface(
        z = p    # p is a 2D square matrix.
    )
]
data[0]['surfacecolor'] = u   #Setting surface color with another 2D square matrix `u` of the same shape as `p` 

layout = go.Layout(
         xaxis = go.layout.XAxis(
        title = go.layout.xaxis.Title(
                  text='x Axis'),
         font=dict(
         family='Courier New, monospace',
         size=18,
         color='#7f7f7f'
         )
    ),
    title = go.layout.Title(
        text='Mean Pressure Field 0.25 Granularity, Colored by Mean Particle Velocity (X-direction)'
    ),
    autosize=False,
    width=1000,
    height=1000,
    margin=dict(
        l=65,
        r=50,
        b=65,
        t=90
    ),
)

fig = go.Figure(data=data, 
                layout=layout)

py.iplot(fig, filename='saveplot.png')

这是我用上面的代码生成的图(指定了 X 轴的新标题)。请注意,x 轴标签与指定的新标题不匹配。

替换此块:

xaxis = go.layout.XAxis(
        title = go.layout.xaxis.Title(
                  text='x Axis'),
         font=dict(
         family='Courier New, monospace',
         size=18,
         color='#7f7f7f'
         )
    )

由此:

scene = dict(
                    xaxis = dict(
                        title='X AXIS TITLE'),
                        font=dict(
                                  family='Courier New, monospace',
                                  size=18,
                                  color='#7f7f7f')
                    yaxis = dict(
                        title='Y AXIS TITLE'),
                    zaxis = dict(
                        title='Z AXIS TITLE'),),

参见this source。有任何问题欢迎随时提问!