I have x:size(1,271,1),y:size(70,271,1). Then I have to attribute 70 sets of numbers(size(1,271,1)) to each line the color varies with its magnitude. My way is
fig,axs = plt.subplots()
for mm in range(0, 70):
plt.plot(x, y[mm])
plt.ylim(min, max)
plt.xlim(0, x[-1])
norm = plt.Normalize(-0.5,0.5)
for ii in range(0,70):
points = np.array([a, y[ii]]).T.reshape(-1, 1, 2)
tmp = np.concatenate([points[:-1],points[1:]],axis=1)
lc = LineCollection(tmp,cmap='viridis',norm=norm)
lc.set_array(color[ii])
line = axs.add_collection(lc[ii])
plt.colorbar(line, ax=axs)
For example,my goal is if there are three lists x = [0,1,2];y = [[2,3,4],[4,5,6]];color = [[0.1,0.3,0.5],[1,0.4,0.6]] as the following figure for continuously multicolored line. example
but no lines come out even the y limit is worng. Two figures come at the same timeMy result