histo_2d_b.py 559 B

1234567891011121314151617181920212223242526
  1. """Histogram of 2 variables as 3D bars"""
  2. import numpy as np
  3. from vedo import Points, show
  4. from vedo.pyplot import histogram
  5. n = 1000
  6. x = np.random.randn(n)*1.5 + 60
  7. y = np.random.randn(n) + 70
  8. histo = histogram(
  9. x, y,
  10. bins=(12, 10),
  11. cmap="summer",
  12. ztitle="Number of entries in bin",
  13. mode="3d",
  14. gap=0.0,
  15. zscale=0.4, # rescale the z axis
  16. aspect=16/9,
  17. )
  18. print(histo.frequencies)
  19. # Add also the original points on top
  20. histo += Points(np.c_[x, y]).z(3).c("red5").point_size(4)
  21. show(histo, __doc__, elevation=-80).close()