def plot_colored_line(x,y, color, cmap = 'spectral_r', line_width = 2):
"""Plot a line with color code"""
segments = np.array([x, y]).T.reshape(-1, 1, 2);
segments = np.concatenate([segments[:-1], segments[1:]], axis=1);
lc = LineCollection(segments, cmap=cmap);
lc.set_array(np.array(color));
#lc.set_linewidth(line_width);
plt.gca().add_collection(lc)
评论列表
文章目录