直方图的代码是
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')
nbins = 1000
mean_list = [366, 657, 594, 1200]
scale_list = [15,50,19,7]
height_list = [1200, 300, 900, 600]
n = 0
for z in [30, 15, 10, 0]:
ys = np.random.normal(loc=mean_list[n], scale=scale_list[n], size=height_list[n]) # loc is mean
hist, bins = np.histogram(ys, bins=int(nbins/10))
xs = (bins[:-1] + bins[1:])/2
ax.bar(xs, hist, zs=z, zdir='y', alpha=0.8)
n += 1
plt.show()