mplot3d (Matplotlib) X 和 Y 轴限制问题

问题描述

我一直在使用 matplotlib 的 mplot3d 库来做一些 3D 绘图。我在 X 和 Y 中有大量范围的数据集,需要更改它们的限制以查看我的绘图上的兴趣点。但是,当我将 x_lim 和 y_lim(或 x_lim3d/y_lim3d)用于我的绘图时,它会破坏图像并且无法在绘图上显示轴。如果有人有使用该工具包的经验并且知道出了什么问题,那就太好了。谢谢。

from matplotlib import colors
from matplotlib import cm
from mpl_toolkits.mplot3d import Axes3D

fig = plt.figure()
ax = fig.gca(projection='3d')

# Plot the surface.
surf = ax.plot_surface(X,Y,Z,cmap=cm.coolwarm,cstride=1,rstride=1,linewidth=0,antialiased=False)
#display colorbar
fig.colorbar(surf,shrink=0.5,aspect=10)

plt.show()

Output of plot without any limits on the x and y axes.

from matplotlib import colors
from matplotlib import cm
from mpl_toolkits.mplot3d import Axes3D

fig = plt.figure()
ax = fig.gca(projection='3d')

# Plot the surface.
surf = ax.plot_surface(X,antialiased=False)
#Setting x and y limits

leftx,rightx = ax.set_xlim(-10,10)
lefty,righty = ax.set_ylim(-10,10)
ax.set_xlim(leftx,rightx)
ax.set_ylim(lefty,righty)

#display colorbar
fig.colorbar(surf,aspect=10)

plt.show()

Output plot of above code,x and y axes are limited and the image is blown out atop of the axes.

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...