colormaps.py 706 B

123456789101112131415161718192021222324252627282930313233
  1. """
  2. Example usage of cmap() to assign a color to each mesh vertex
  3. by looking it up in matplotlib database of colormaps
  4. """
  5. from vedo import Plotter, Mesh, dataurl
  6. print(__doc__)
  7. # these are the some matplotlib color maps
  8. maps = [
  9. "afmhot",
  10. "binary",
  11. "bone",
  12. "cool",
  13. "coolwarm",
  14. "copper",
  15. "gist_earth",
  16. "gray",
  17. "hot",
  18. "jet",
  19. "rainbow",
  20. "winter",
  21. ]
  22. mug = Mesh(dataurl+"mug.ply")
  23. scalars = mug.coordinates[:, 1] # let y-coord be the scalar
  24. plt = Plotter(N=len(maps))
  25. for i, key in enumerate(maps): # for each available color map name
  26. imug = mug.clone(deep=False).cmap(key, scalars, n_colors=5)
  27. plt.at(i).show(imug, key)
  28. plt.interactive().close()