def colorline(x, y, colors=None, linewidth=3, alpha=1.0):
 colors = ['r', 'g', 'b', 'c', 'y', 'm', 'k']
 widths = [5, 10, 20, 40, 20, 10, 5]
 segments = make_segments(x, y)
 lc = LineCollection(segments, colors=colors, linewidth=widths, alpha=alpha)
 ax = plt.gca()
 ax.add_collection(lc)
 return lc

def colorline ( x , y , colors = None , linewidth = 3 , alpha = 1.0 ) : colors = [ 'r' , 'g' , 'b' , 'c' , 'y' , 'm' , 'k' ] widths = [ 5 , 10 , 20 , 40 , 20 , 10 , 5 ] segments = make_segments ( x , y ) lc = LineCollection ( segments , colors = colors , linewidth = widths , alpha = alpha ) ax = plt . gca ( ) ax . add_collection ( lc ) return lc
plot a line with segments .