你不能用imshow做到這一點,但你可以用contourf,如果這對你有用。這是一個有點雜牌的,但:
from mpl_toolkits.mplot3d import Axes3D
import numpy as np
import matplotlib.pyplot as plt
fig = plt.figure()
ax = fig.gca(projection='3d')
x = np.linspace(0, 1, 100)
X, Y = np.meshgrid(x, x)
Z = np.sin(X)*np.sin(Y)
levels = np.linspace(-1, 1, 40)
ax.contourf(X, Y, .1*np.sin(3*X)*np.sin(5*Y), zdir='z', levels=.1*levels)
ax.contourf(X, Y, 3+.1*np.sin(5*X)*np.sin(8*Y), zdir='z', levels=3+.1*levels)
ax.contourf(X, Y, 7+.1*np.sin(7*X)*np.sin(3*Y), zdir='z', levels=7+.1*levels)
ax.legend()
ax.set_xlim3d(0, 1)
ax.set_ylim3d(0, 1)
ax.set_zlim3d(0, 10)
plt.show()
的什麼在3D實現的文檔是here。
正如ali_m建議,如果這不適合你,如果你可以想象它,你可以用VTk/MayaVi做到這一點。
你也應該看看'mayavi',它可以進行本地opengl渲染,並有更好的3D可視化工具。 – tacaswell 2013-03-30 23:55:10