xdat = np.arange(0, 90.1)
ydat = [np.sin(0.2 * (xdat - t) / np.pi) for t in tim]
cm1 = mcol.LinearSegmentedColormap.from_list('MyCmapName', ['r', 'b'])
cnorm = mcol.Normalize(vmin=min(tim), vmax=max(tim))
cpick = cm.ScalarMappable(norm=cnorm, cmap=cm1)
cpick.set_array([])
F = plt.figure()
A = F.add_subplot(111)
for y, t in zip(ydat, tim):
    A.plot(xdat, y, color=cpick.to_rgba(t))
plt.colorbar(cpick, label='Time (seconds)')
Python: making color bar that runs from red to blue