import matplotlib.pyplot as plt
import numpy as np
from mpl_toolkits.mplot3d import Axes3D
fig = plt.figure()
ax = fig.add_axes(Axes3D(fig))
X = np.arange(-4, 4, 0.25)
Y = np.arange(-4, 4, 0.25)
X, Y = np.meshgrid(X, Y)
R = np.sqrt(X**2+Y**2)
Z = np.sin(R)
ax.plot_surface(X, Y, Z, rstride=1, cstride=1, cmap='rainbow')
ax.contourf(X, Y, Z, zdir='x', offset=4, cmap='rainbow')
ax.set_zlim(-2, 2)
plt.show()
plot_surface中rstride和cstride表示的网格的row(x),column(y)方向的步幅(stride有步幅的意思)
将cstride和rstride改为2
zdir指的是从哪个轴投影下去,offset表示的是投影所在的位置
向x轴方向投影,offset=2,改为offset=4
标签:plot,surface,函数参数,fig,offset,np,ax From: https://blog.csdn.net/2302_80063517/article/details/140254730