Shaded Vector FieldsΒΆ

../../_images/shaded_vectors.png

For vectors, shading is applied to darken vectors aligned with the view direction, emphasizing vectors aligned perpendicular view direction.

import numpy as np
from matplotlib import pyplot as plt
import s3dlib.surface as s3d

# Vector shading with fading

rez, vlen, minmax = 3, 0.7, (-1.3,1.3)
label = ['\nvectors','\nshaded vectors' ]
fig = plt.figure(figsize=(8,4),facecolor='k')
for i in range(2) :
    ax = fig.add_subplot(121+i, projection='3d', aspect='equal',proj_type='ortho', facecolor='k')
    ax.set(xlim=minmax, ylim=minmax, zlim=minmax,
        xlabel='X', ylabel='Y', zlabel='Z')
    ax.set_title(label[i], c='w')
    ax.set_axis_off()

    surface = s3d.SphericalSurface(rez, basetype='octa', color='w')
    vnorms = surface.vertexnormals(scale=vlen)
    if i==1 : vnorms.shade().fade() # use default direction & view

    ax.add_collection3d(vnorms)

fig.tight_layout()
plt.show()