我需要在Python中创建尺寸为1000x1000的3D高度图,并且其高度应为0-255。我做了一些,但是Z轴居中对齐。如何使Z轴从底部开始?
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
import numpy as np
fig = plt.figure()
ax = fig.gca(projection='3d')
ax.set_zlim(bottom=0, top=256)
X = np.arange(0, 1000, 1)
Y = np.arange(0, 1000, 1)
X, Y = np.meshgrid(X, Y)
Z = np.random.randint(256, size = (1000, 1000) )
surf = ax.plot_surface(X, Y, Z)
plt.show()
我想做这样的事情:
但是我得到了: