当我为三维图形设置等宽高比时,z轴不会更改为“等宽”。所以,这个:
fig = pylab.figure()
mesFig = fig.gca(projection='3d', adjustable='box')
mesFig.axis('equal')
mesFig.plot(xC, yC, zC, 'r.')
mesFig.plot(xO, yO, zO, 'b.')
pyplot.show()
给我以下信息:
显然,z轴的单位长度不等于x和y单位。
如何使三个轴的单位长度相等?我能找到的所有解决办法都不管用。谢谢您。
Tags:
我喜欢上面的解决方案,但它们的缺点是,您需要跟踪所有数据的范围和平均值。如果有多个将一起绘制的数据集,这可能会很麻烦。为了解决这个问题,我使用了ax.get_xyz]lim3d()方法,并将整个过程放入一个独立的函数中,在调用plt.show()之前只需调用一次。以下是新版本:
我使用
set_x/y/zlim
functions简化了Remy F的解。我相信matplotlib还没有在3D中正确设置等轴。。。但我在几天前发现了一个我已经适应了的技巧(我不记得在哪里)。其概念是在数据周围创建一个伪立方体边界框。 您可以使用以下代码对其进行测试:
z数据的数量级大约大于x和y,但即使使用等轴选项,matplotlib也会自动缩放z轴:
但是,如果添加边界框,则可以获得正确的缩放比例:
相关问题 更多 >
编程相关推荐