histo_3d.py 547 B

1234567891011121314151617
  1. """Histogram (or plot) in 3D.
  2. The size of each cube is proportional to the value at that point"""
  3. import numpy as np
  4. from vedo import Volume, Cube, Glyph, show
  5. # Make up some arbitrary data
  6. X, Y, Z = np.mgrid[:10, :6, :4]
  7. counts = 50 - ( (X-4)**2 + (Y-4)**2 + (Z-4)**2 )
  8. # This is now a point cloud with an associated array of counts
  9. pcloud = Volume(counts).topoints()
  10. marker = Cube().scale(0.015)
  11. glyphed_pcl = Glyph(pcloud, marker, scale_by_scalar=True)
  12. glyphed_pcl.cmap('seismic').add_scalarbar('counts')
  13. show(glyphed_pcl, __doc__, axes=1)