无法在python的绘图表面图中更改轴标题

Nik*_*il 4 python data-visualization axis-labels plotly

我正在使用 plotly 版本 3.9.0 和 python 3.7 。我正在尝试使用 python 渲染一个简单的表面图。我已经使用预期的配色方案成功渲染了绘图,但是在更改 X、Y、Z 轴的轴标题以及控制每个轴的刻度频率和刻度标签时遇到了问题。我已经尝试了其他相关问题中的一些解决方案,但没有取得多大成功。因此,我想在下面发布我的代码片段,以寻求 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')

Run Code Online (Sandbox Code Playgroud)

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

3D 曲面图 Plotly Python

Mik*_*e_H 9

替换此块:

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

这样:

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'),),
Run Code Online (Sandbox Code Playgroud)

看到这个来源。随时提出更多问题!