Base Class LinesΒΆ

../../_images/cubelines1.png

Six lines are defined in the boxIndices list with the first and last line composed of four segments. The six line colors are set uing the six color boxColor list.

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

#.. Base Class Lines

# 1. Define geometry to examine .....................................

boxVerts = [
    [  1.0,  1.0,  1.0] ,
    [ -1.0,  1.0,  1.0] ,
    [ -1.0, -1.0,  1.0] ,
    [  1.0, -1.0,  1.0] ,

    [  1.0,  1.0, -1.0] ,
    [ -1.0,  1.0, -1.0] ,
    [ -1.0, -1.0, -1.0] ,
    [  1.0, -1.0, -1.0] 
]

boxIndices = [ [4,5,6,7,4], [4,0], [5,1], [6,2], [7,3], [0,1,2,3,0] ]
boxColor = [ 'r','g','b','c','m','y']

# 2. Setup and map line .............................................

box= s3d.ColorLine3DCollection(boxVerts,boxIndices,color=boxColor,linewidth=2)

# 3. Construct figure, add surface, and plot ........................

fig = plt.figure(figsize=plt.figaspect(1))

ax = plt.axes(projection='3d')
minmax = (-1.5,1.5)
ax.set(xlim=minmax, ylim=minmax, zlim=minmax )
ax.set_title(str(box), fontsize='small')
ax.set_proj_type('ortho')

ax.add_collection3d(box)

fig.tight_layout()
plt.show()