manyspheres.py 684 B

1234567891011121314151617181920
  1. """Example that shows how to draw very large number
  2. of spheres (same for Points, Lines) with different
  3. colors or different radii, N="""
  4. from random import gauss
  5. from vedo import show, Spheres
  6. N = 50000
  7. cols = range(N) # color numbers
  8. pts = [(gauss(0, 1), gauss(0, 2), gauss(0, 1)) for i in cols]
  9. rads = [abs(pts[i][1]) / 10 for i in cols] # radius=0 for y=0
  10. # all have same radius but different colors:
  11. s0 = Spheres(pts, c=cols, r=0.1, res=5) # res= theta-phi resolution
  12. show(s0, __doc__+str(N), at=0, N=2, axes=1, viewup=(-0.7, 0.7, 0))
  13. # all have same color but different radius along y:
  14. s1 = Spheres(pts, r=rads, c="lb", res=8)
  15. show(s1, at=1, axes=2).interactive().close()