表面PYTHON上的3D点

时间:2019-03-16 12:16:12

标签: python python-3.x numpy matplotlib plot

我正在尝试在表面上绘制一些点。我想要得到的结果是(右图): enter image description here

我尝试了以下代码(x_k包含我要绘制的点的坐标):

f = lambda x : x[0]**2+x[1]**3+3*x[0]*x[1]
x_axis = [x_k[i][0] for i in range(0, len(x_k))]
y_axis = [x_k[i][1] for i in range(0, len(x_k))]
z_axis = [f(x_k[i]) for i in range(0, len(x_k))]

x = np.linspace(-6, 6, 30)
y = np.linspace(-6, 6, 30)

X, Y = np.meshgrid(x, y)
Z = f(np.array([X, Y]))

ax = plt.axes(projection='3d')
ax.plot_surface(X, Y, Z,alpha=0.8,cmap='viridis',edgecolor='white',linewidth=0.3)
ax.scatter(x_axis, y_axis, z_axis, zdir='z',marker='.', s=10, c='black', depthshade=False)
ax.set_xlabel('x')
ax.set_ylabel('y')
ax.set_zlabel('z')
ax.set_aspect("equal")
plt.tight_layout()
plt.show()

我得到这个: enter image description here

请注意,由于表面原因,这些点是透明的...

enter image description here

我希望它们是黑色的,以便更好地看到它们。我该怎么办?谢谢!

0 个答案:

没有答案