glyphs3.py 801 B

12345678910111213141516171819202122
  1. """Orient and scale 'glyphs'
  2. (use a Mesh like a symbol)"""
  3. # Credits: original example and data from https://plotly.com/python/cone-plot
  4. # Adapted for vedo by M. Musy, 2020.
  5. from vedo import Cone, Glyph, show
  6. import numpy as np
  7. import pandas as pd
  8. # Read cvs data
  9. df = pd.read_csv("https://raw.githubusercontent.com/plotly/datasets/master/vortex.csv")
  10. pts = np.c_[df['x'], df['y'],df['z']]
  11. vecs= np.c_[df['u'], df['v'],df['w']]
  12. # Create a mesh to be used like a symbol (a "glyph") to be attached to each point
  13. cone = Cone().scale(0.3).rotate_y(90) # make it smaller and orient tip to positive x
  14. glyph = Glyph(pts, cone, vecs, scale_by_vector_size=True, color_by_vector_size=True)
  15. glyph.lighting('ambient').cmap('Blues').add_scalarbar(title='wind speed')
  16. show(glyph, __doc__, axes=True).close()