如何在 Plotly (Python) 中扩大曲面图与其投影平面之间的间距?

How to widen the spacing between the surface plot and its projected planes in Plotly (Python)?

我使用 Plotly (Python) 库创建了一个 3D 表面图。但是 x 和 z 投影平面 上的投影线很难看清,因为它们离曲面图太近了。关于如何扩大曲面图与其 x 和 z 投影平面之间的间距的任何想法?

import pandas as pd
import plotly.graph_objects as go


src = 'https://raw.githubusercontent.com/plotly/datasets/master/api_docs/mt_bruno_elevation.csv'
z = pd.read_csv(src).values

fig = go.Figure(
    data=[
        go.Surface(
            z=z,
            contours=dict(
                x=dict(show=True, highlightcolor='limegreen', project_x=True),
                z=dict(show=True, highlightcolor='limegreen', project_z=True)
            )
        )
    ]
)
fig.update_layout(
    width=800, 
    height=800,
)
fig.show()

您可以尝试手动设置 y-axis 和 z-axis 范围的下限。这将在 Plotly 渲染曲面图时增加投影和曲面之间的间距。

import pandas as pd
import plotly.graph_objects as go


src = 'https://raw.githubusercontent.com/plotly/datasets/master/api_docs/mt_bruno_elevation.csv'
z = pd.read_csv(src).values

fig = go.Figure(
    data=[
        go.Surface(
            z=z,
            contours=dict(
                x=dict(show=True, highlightcolor='limegreen', project_x=True),
                z=dict(show=True, highlightcolor='limegreen', project_z=True)
            )
        )
    ]
)


fig.update_layout(
    scene = dict(
        xaxis = dict(range=[-5,25]),
        zaxis = dict(range=[-50,500],),),
    width=800,
    height=800
)

fig.show()