scatter3.py 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. """Create a scatter plot to overlay
  2. three different distributions"""
  3. from vedo import *
  4. from numpy.random import randn
  5. ### first cloud in blue, place it at z=0:
  6. x = randn(2000) * 3
  7. y = randn(2000) * 2
  8. xy = np.c_[x, y]
  9. pts1 = Points(xy).z(0.0).color("blue5",0.5)
  10. bra1 = Brace([-7, -8], [7, -8], comment="whole population", s=0.4).c("blue5")
  11. ### second cloud in red
  12. x = randn(1200) + 4
  13. y = randn(1200) + 2
  14. xy = np.c_[x, y]
  15. pts2 = Points(xy).z(0.1).color("red",0.5)
  16. bra2 = Brace(
  17. [8, 2, 0.3],
  18. [6, 5, 0.3],
  19. comment="red zone",
  20. angle=180,
  21. justify="bottom-center",
  22. c="red5",
  23. )
  24. ### third cloud with a black marker
  25. x = randn(20) + 4
  26. y = randn(20) - 4
  27. mark = Marker("*", s=0.25)
  28. pts3 = Glyph(xy, mark).z(0.2).color("red5",0.5)
  29. bra3 = Brace([8, -6], [8, -2], comment="my stars").z(0.3)
  30. # some text message
  31. msg = Text3D("preliminary\nresults!", font="Quikhand", s=1.5).c("black")
  32. msg.rotate_z(20).pos(-10, 3, 0.2)
  33. show(
  34. pts1, pts2, pts3, msg, bra1, bra2, bra3, __doc__,
  35. axes=1, zoom=1.2, mode="image",
  36. ).close()