histo_polar.py 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. from vedo import Hyperboloid, show
  2. from vedo.pyplot import histogram
  3. import numpy as np
  4. np.random.seed(1)
  5. ##################################################################
  6. radhisto = histogram(
  7. np.random.rand(200)*6.28,
  8. mode='polar',
  9. title="random orientations",
  10. bins=10,
  11. c=range(10), #'orange', #uniform color
  12. alpha=0.8,
  13. labels=["label"+str(i) for i in range(10)],
  14. )
  15. show(radhisto, at=0, N=2, axes=0, sharecam=False)
  16. ##################################################################
  17. hyp = Hyperboloid(res=20).cut_with_plane().rotate_y(-90)
  18. hyp.color('grey').alpha(0.3)
  19. # select 10 random indices of points on the surface
  20. idx = np.random.randint(0, hyp.npoints, size=10)
  21. radhistos = []
  22. for i in idx:
  23. #generate a random histogram
  24. rh = histogram(
  25. np.random.randn(100),
  26. mode='polar',
  27. bins=12,
  28. r1=0.2, # inner radius
  29. phigap=1.0, # leave a space btw phi bars
  30. cmap='viridis_r',
  31. show_disc=False,
  32. show_angles=False,
  33. show_errors=False,
  34. )
  35. rh.scale(0.15) # scale histogram to make it small
  36. rh.pos(hyp.points[i]) # set its position on the surface
  37. radhistos.append(rh)
  38. show(hyp, radhistos, at=1).interactive().close()