I have multiple 1D NumPy arrays with variable sizes and I want to plot their histograms in a 3d plot. The best I can reach was using the following code:
#Histograms
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
nbins = 30
z_array = np.linspace(0,420,22)
for a,z in zip(arrays1, z_array):
ys = a
hist, bins = np.histogram(ys, bins=nbins,density=True)
xs = (bins[:-1] + bins[1:])/0.5
print(xs.shape)
ax.bar(xs, hist, zs=z, zdir='y', alpha=0.8)
ax.set_xlabel('X')
ax.set_ylabel('Y')
ax.set_zlabel('Z')
plt.show()
The histograms don't look good and I have no clue how to adjust the bin size and also the spacing in between the histograms.