issue_1025.py 919 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. from vedo import *
  2. colors = [
  3. "black",
  4. "lightgreen",
  5. "orange",
  6. "yellow",
  7. "green",
  8. "lightblue",
  9. "pink",
  10. "red",
  11. "cyan",
  12. "yellow",
  13. "blue",
  14. "tomato",
  15. "violet",
  16. "brown",
  17. ]
  18. n = len(colors)
  19. x = np.linspace(0, n, n+1)
  20. # x = np.sqrt(np.linspace(0, n, n+1))
  21. vals = x.copy()[1:]
  22. print(vals)
  23. xyz = np.concatenate((x[:, None], np.ones((n+1, 2))), axis=-1)
  24. xyz_segments = np.stack((xyz[:-1, :], xyz[1:, :]), axis=1)
  25. lines0 = Lines(xyz_segments, lw=8)
  26. lines0.cmap(colors, vals, on="cells")
  27. lines1 = Lines(xyz_segments, lw=8).shift(0,-0.2)
  28. table = [(x, color) for x, color in zip(vals, colors)]
  29. clut = build_lut(table, vmin=vals[0], interpolate=0)
  30. print("table:", table)
  31. lines1.cmap(clut, vals, on="cells")
  32. pts = Points(xyz, c='black', r=8)
  33. plt = Plotter()
  34. plt += [pts, pts.labels2d('id'), lines0, lines1]
  35. plt.show("Colors must match", size=(1200,300), zoom=3.5).close()