Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/user-interface/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 三维条形图增加条形图的平方面积_Python_Matplotlib_3d - Fatal编程技术网

Python 三维条形图增加条形图的平方面积

Python 三维条形图增加条形图的平方面积,python,matplotlib,3d,Python,Matplotlib,3d,我从一个分布中绘制了以下代码,然后绘制了与bin中的频率对应的3d直方图 # Given a data array of x and y such that they correspond # to a number of points, this draws a 3d Bar Graph corresponding # to density of points. def hist_3dBar(x,y,bins): fig = plt.figure() ax = Axes3D(f

我从一个分布中绘制了以下代码,然后绘制了与bin中的频率对应的3d直方图

# Given a data array of x and y such that they correspond
# to a number of points, this draws a 3d Bar Graph corresponding
# to 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
使用调用它的代码:

# Produce a number of points in x-y from another 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)
我只是想让这些条彼此相邻,底部没有空格。另外,如何根据箱子中的频率获取颜色代码

谢谢