File: histo_3d.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 (17 lines) | stat: -rw-r--r-- 547 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
"""Histogram (or plot) in 3D.
The size of each cube is proportional to the value at that point"""
import numpy as np
from vedo import Volume, Cube, Glyph, show

# Make up some arbitrary data
X, Y, Z = np.mgrid[:10, :6, :4]
counts = 50 - ( (X-4)**2 + (Y-4)**2 + (Z-4)**2 )

# This is now a point cloud with an associated array of counts
pcloud = Volume(counts).topoints()

marker = Cube().scale(0.015)
glyphed_pcl = Glyph(pcloud, marker, scale_by_scalar=True)
glyphed_pcl.cmap('seismic').add_scalarbar('counts')

show(glyphed_pcl, __doc__, axes=1)