我希望能够看到 3D 表面上的线(和点)位于表面顶部(第二张图像),而不是后面(第一张图像)。这是我的 3D 函数:
def f(x, y):
return np.sin(2*x) * np.cos(2*y)
Run Code Online (Sandbox Code Playgroud)
3D 表面的 X、Y、Z:
x = np.linspace(-2, 2, 100)
y = np.linspace(-2, 2, 100)
X, Y = np.meshgrid(x, y)
Z = f(X, Y)
Run Code Online (Sandbox Code Playgroud)
我生成了 x 点 (xx) 和 y 点 (yy) 的向量,其中 zz = f(xx,yy)
fig = plt.figure(figsize=(8,6))
ax = plt.axes(projection='3d')
ax.scatter(xx, yy, zz, c='r', marker='o')
#ax.plot(xx,yy,zz, c= 'r')
ax.plot_surface(X, Y, Z, rstride=1, cstride=1,
cmap='viridis', edgecolor='none')
Run Code Online (Sandbox Code Playgroud)
正如你所看到的,点在图后面,图形覆盖了点。我想看看情节上的要点。我应该怎么办?
我希望能够看到像这样的点和线:
编辑:这是我生成点的方式:
for i in range(1,2000):
[a, b] = np.random.rand(2,1)*np.sign(np.random.randn(2,1))*2
xx = …Run Code Online (Sandbox Code Playgroud)