我尝试了以下代码(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()
请注意,由于表面原因,这些点是透明的...
我希望它们是黑色的,以便更好地看到它们。我该怎么办?谢谢!