Former-commit-id:a02aeb236c
[formerly9f19e3f712
] [formerlya02aeb236c
[formerly9f19e3f712
] [formerly06a8b51d6d
[formerly 64fa9254b946eae7e61bbc3f513b7c3696c4f54f]]] Former-commit-id:06a8b51d6d
Former-commit-id:8e80217e59
[formerly3360eb6c5f
] Former-commit-id:377dcd10b9
22 lines
524 B
Python
Executable file
22 lines
524 B
Python
Executable file
from mpl_toolkits.mplot3d import Axes3D
|
|
import matplotlib.pyplot as plt
|
|
import numpy as np
|
|
|
|
fig = plt.figure()
|
|
ax = Axes3D(fig)
|
|
x, y = np.random.rand(2, 100) * 4
|
|
hist, xedges, yedges = np.histogram2d(x, y, bins=4)
|
|
|
|
elements = (len(xedges) - 1) * (len(yedges) - 1)
|
|
xpos, ypos = np.meshgrid(xedges[:-1]+0.25, yedges[:-1]+0.25)
|
|
|
|
xpos = xpos.flatten()
|
|
ypos = ypos.flatten()
|
|
zpos = np.zeros(elements)
|
|
dx = 0.5 * np.ones_like(zpos)
|
|
dy = dx.copy()
|
|
dz = hist.flatten()
|
|
ax.bar3d(xpos, ypos, zpos, dx, dy, dz, color='b')
|
|
|
|
plt.show()
|
|
|