我有这个情节:
# only for example, use your grid
z = np.linspace(0, 1, 10)
x = np.linspace(0, 1, 15)
y = np.linspace(0, 1, 15)
U = np.zeros((15,15,10),dtype=float)
for i in range(10):
for j in range(15):
for k in range(15):
U[k,j,i] = np.exp(-(x[k]/2) ** 2 - (y[j]/3) ** 2 - z[i]** 2)
X, Y, Z = np.meshgrid(x, y, z)
# Creating figure
fig = plt.figure()
ax = plt.axes(projection="3d")
# Creating plot
p = ax.scatter3D(X, Y, Z, c=U, alpha=0.7, marker='.')
ax.set_xlabel('x')
ax.set_ylabel('y')
ax.set_zlabel('z')
fig.colorbar(p,ax=ax)
plt.show()
如何在surface3D图中转换这个Scatter3D图?换句话说,如何保持 x、y、z 轴并用颜色为 U 的磁体的表面绘制?
像这样的东西: