python - 3D bar graph increase square area of Bar -


i have following code drawing distribution , plots 3d histogram corresponding frequency in bin.

# given data array of x , y such correspond # number of points, draws 3d bar graph corresponding # density of points. def hist_3dbar(x,y,bins):     fig = plt.figure()     ax = axes3d(fig)     hist, xedges, yedges = np.histogram2d(x,y,bins)     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 = np.ones_like(zpos)     dy = dx.copy()     dz = hist.flatten()     ax.bar3d(xpos, ypos, zpos, dx, dy, dz, color='b', zsort='average')     return fig 

with code calls it:

# produce number of points in x-y distribution. mean = [0,0] cov = [[3,2],[2,3]]  xp,yp = np.random.multivariate_normal(mean,cov,1000).t plt.plot(xp,yp,'o'); plt.axis('equal'); plt.show() hist_3d = gauss.hist_3dbar(x,y,10) 

i want make bars adjacent each other, no whitespace on bottom. also, how can color code according frequency in bin?

thanks!


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -