Python画四维投影的三维图像
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
import numpy as np
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
u = np.linspace(0, 2 * np.pi, 100)
v = np.linspace(0, np.pi, 100)
x = 10 * np.outer(np.cos(u), np.sin(v))
y = 10 * np.outer(np.sin(u), np.sin(v))
z = 10 * np.outer(np.ones(np.size(u)), np.cos(v))
z1 = z * np.cos(0.5*x)
N = z1 / z1.max() # normalize 0..1
#plt.cm.颜色类型
surf = ax.plot_surface(x, y, z, rstride=1, cstride=1, facecolors=plt.cm.hot(N), linewidth=0, antialiased=False, shade=False)
m = plt.cm.ScalarMappable(cmap=plt.cm.hot)
m.set_array(z1)
plt.colorbar(m)
plt.show()
img/