简体   繁体   English

Python Plot 3D 直方图六边形

[英]Python Plot 3D Histogram Hexagon

I'm testing a TOF camera from Broadcom.我正在测试 Broadcom 的 TOF 相机。 It has hexagonal pixels.它有六边形像素。 Broadcom 像素的表示

I wish to represent the histogram in 3D as in the utility of the constructor.我希望在 3D 中表示直方图,就像在构造函数的实用程序中一样。

直方图 Hexa 到 Broadcom GUI

I tested the vedo library.我测试了 vedo 库。 But I can't give the values in Z and reorder the cells and trace to the ground但我无法给出 Z 中的值并重新排序单元格并追踪到地面

Vedo的测试

   from vedo import *
   from vedo.pyplot import histogram
   import numpy as np

   N = 2000
   x = np.random.randn(N) * 1.0
   y = np.random.randn(N) * 1.5
   # hexagonal binned histogram:
   histo = histogram(x, y,
              bins=100,
              mode='hexbin',
              xtitle="\sigma_x =1.0",
              ytitle="\sigma_y =1.5",
              ztitle="counts",
              fill=True,
              cmap='terrain',
              )
   # add a formula:
   f = r'f(x, y)=A \exp \left(-\left(\frac{\left(x-x_{o}\right)^{2}}'
   f+= r'{2 \sigma_{x}^{2}}+\frac{\left(y-y_{o}\right)^{2}}'
   f+= r'{2 \sigma_{y}^{2}}\right)\right)'
   formula = Latex(f, c='k', s=1.5).rotateX(90).rotateZ(90).pos(1.5,-2,1)

   show(histo, formula, axes=1, viewup='z')

You can easily create it with eg您可以使用例如轻松创建它

from vedo import *
import numpy as np

settings.defaultFont = "Theemim"

vals = np.abs(np.random.randn(8*4)) # heights
cols = colorMap(vals, "RdYlBu")

items = []
k = 0
for i in range(8):
    for j in range(4):
        val = vals[k]
        col = cols[k]
        x, y, z = [i+j%2/2, j-j%2/6, val+0.01]
        hexa = Circle([x,y], r=0.55, res=6)
        hbar = hexa.extrude(val) # create the hex bar
        hbar.lighting("default").flat().c(col)
        txt = Text3D(precision(val,3), [x,y,z], s=.12, justify='center', c='k')
        items += [hbar, txt]
        k += 1

show(items, axes=dict(xtitle="x-cell"))

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM