File: plot_hexcells.py

package info (click to toggle)
vedo 2025.5.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 10,404 kB
  • sloc: python: 64,792; javascript: 1,932; xml: 437; sh: 139; makefile: 6
file content (23 lines) | stat: -rw-r--r-- 692 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
"""3D Bar plot of a TOF camera with hexagonal pixels"""
from vedo import *
import numpy as np

settings.default_font = "Glasgo"
settings.use_parallel_projection = True

vals = np.abs(np.random.randn(4*6))  # pixel heights
cols = color_map(vals, "summer")

k = 0
items = [__doc__]
for i in range(4):
    for j in range(6):
        val, col= vals[k], cols[k]
        x, y, z = [i+j%2/2, j/1.155, val+0.01]
        zbar= Polygon([x,y,0], nsides=6, r=0.55, c=col).extrude(val)
        line= Polygon([x,y,z], nsides=6, r=0.55, c='k').wireframe().lw(2)
        txt = Text3D(f"{i}/{j}", [x,y,z],s=0.15, c='k', justify='center')
        items += [zbar, line, txt]
        k += 1

show(items, axes=7)