def plot(self, ax, color = 'rainbow', linewidth = 3) :
"Simple display using a per-id color scheme."
segs = self.segments()
if color == 'rainbow' : # rainbow color scheme to see pointwise displacements
ncycles = 5
cNorm = colors.Normalize(vmin=0, vmax=(len(segs)-1)/ncycles)
scalarMap = cm.ScalarMappable(norm=cNorm, cmap=plt.get_cmap('hsv') )
seg_colors = [ scalarMap.to_rgba( i % ((len(segs)-1)/ncycles) )
for i in range(len(segs)) ]
else : # uniform color
seg_colors = [ color for i in range(len(segs)) ]
line_segments = LineCollection(segs, linewidths=(linewidth,),
colors=seg_colors, linestyle='solid')
ax.add_collection(line_segments)
评论列表
文章目录