matplotlib 在三维图中指定视点距离的方法

x7rlezfr  于 2023-05-01  发布在  其他
关注(0)|答案(1)|浏览(140)

我正在使用mpl_toolkits制作3D绘图的动画。mplot3d(Matplotlib 3.6.3)并需要设置视距。
Matplotlib的早期版本似乎允许使用以下方法为3D绘图设置视点“相机”的仰角、方位角和距离:

ax.elev = 45
ax.azim = 10
ax.dist = 2

但是distance属性似乎由于某种原因而被弃用:

Warning (from warnings module):
    ax.dist = 2
MatplotlibDeprecationWarning: The dist attribute was deprecated in Matplotlib 3.6 and will be removed two minor releases later.

这仍然运行,但输出图有各种各样的视觉伪影,只有当我用ax关闭轴时才会消失。set_axis_off()。
是否有等效的方法来设置视点距离以放大3中的3D数据集。6.3?

k97glaaz

k97glaaz1#

根据文档,您现在需要使用set_box_aspectzoom参数:
ax.set_box_aspect(None, zoom=2)
其中第一个参数是纵横比。使用None可使用默认值。

相关问题