mu, sigma = 0, 0.1
x = 10 * np.random.normal(mu, sigma, 5000)
y = 10 * np.random.normal(mu, sigma, 5000)
z = 10 * np.random.normal(mu, sigma, 5000)
xyz = np.vstack([x, y, z])
kde = stats.gaussian_kde(xyz)
density = kde(xyz)
figure = mlab.figure('DensityPlot')
pts = mlab.points3d(x, y, z, density, scale_mode='none', scale_factor=0.07)
mlab.axes()
mlab.show()
How to plot a 3D density map in python with matplotlib