首页 > 解决方案 > “nticks”在情节场景中不受 xaxis 的尊重

问题描述

让我们从代码开始:

b_min = [-3, 6, 0]
b_max = [24, 24, 9]
n_vertices = [10, 10, 10]

p_a = [-1, 11, 4.5]
p_b = [11, 9, 9]
p_c = [6, 8, 6]
p_d = [-1, 7, 10]

points = [p_a, p_b, p_c, p_d]

df = pd.DataFrame(points, columns=['x', 'y', 'z'])
figure = px.scatter_3d(df, x='x', y='y', z='z')
figure.update_layout(scene={
    'xaxis': {'nticks': n_vertices[0], 'range': [b_min[0], b_max[0]]},
    'yaxis': {'nticks': n_vertices[1], 'range': [b_min[1], b_max[1]]},
    'zaxis': {'nticks': n_vertices[2], 'range': [b_min[2], b_max[2]]}
})
figure.show()

希望每个轴有 10 个刻度。这适用于轴 y 和 z,但不适用于 x。为什么? 剧情

标签: pythonplotlyplotly-pythonscatter3d

解决方案


在这里查看 scatter3d 轨迹的文档,nticks是轴的最大刻度数,实际刻度数小于或等于nticks.


推荐阅读