plot_hexcells.py 692 B

1234567891011121314151617181920212223
  1. """3D Bar plot of a TOF camera with hexagonal pixels"""
  2. from vedo import *
  3. import numpy as np
  4. settings.default_font = "Glasgo"
  5. settings.use_parallel_projection = True
  6. vals = np.abs(np.random.randn(4*6)) # pixel heights
  7. cols = color_map(vals, "summer")
  8. k = 0
  9. items = [__doc__]
  10. for i in range(4):
  11. for j in range(6):
  12. val, col= vals[k], cols[k]
  13. x, y, z = [i+j%2/2, j/1.155, val+0.01]
  14. zbar= Polygon([x,y,0], nsides=6, r=0.55, c=col).extrude(val)
  15. line= Polygon([x,y,z], nsides=6, r=0.55, c='k').wireframe().lw(2)
  16. txt = Text3D(f"{i}/{j}", [x,y,z],s=0.15, c='k', justify='center')
  17. items += [zbar, line, txt]
  18. k += 1
  19. show(items, axes=7)