我在 matplotlib 中为 3d 图设置限制时遇到问题;我发现无论我如何设置 x、y 和 z 轴的限制,3dplots 的绘图例程都会添加额外的缓冲区。
from mpl_toolkits.mplot3d import Axes3D
from matplotlib import pyplot as plt
fig = plt.figure()
ax = fig.add_subplot(111,projection='3d')
ax.axes.set_xlim3d(left=0, right=10)
ax.axes.set_ylim3d(bottom=0, top=10)
ax.axes.set_zlim3d(bottom=0, top=10)
plt.show()
Run Code Online (Sandbox Code Playgroud)
这会产生以下图:
正如您所看到的,限制应该位于 x, y, z = {0, 10},但是 3D 绘图总是向每个边缘添加一点缓冲区。有谁知道如何关闭此效果?
我还使用过 plt.xlims(); 和 ax.axes.set_xlims() 但它们产生相同的效果。