I'm very new to python and matplotlib, and I want to create a plot with different colored lines. I know I have to use a colormap, but I'm not sure how. So I have a for loop:
for i in range(len(params)):
centers,fN = graph.createHistogram(values = NHI[i])
for j in range(len(centers)):
if params[i]!=fidVal:
vals[j] = (np.log10(origfNHI[j]/fN[j]))/(fidVal-params[i])
plt.plot(centers,vals)
I want to give each line different colors based on the difference between the value of params[i] and fidVal. If fidVal - params[i] is a negative large number, I want the line to be very red, and if it is a negative small number, I want it to be not as red. Similarly if fidVal - params[i] is positive, I want it to be blue based on that value. Finally, I want the colors to be mapped on a colorbar which would be displayed on the plot.
Alternatively, is there a way I can specify the rgb color of a line when I use plt.plot()? Like, could I say plt.plot(centers,vals,Color(0,0,0))?
What code should I use to solve this problem?
