I have a vector x to be plotted, and I want to change the line color depending on the values of a different vector s. Both vectors are the same length, and s only contains 0s and 1s.
I have tried creating a color object such as colors = ['red' if i < 0.5 else 'blue' for i in s]
, but i get a typeValue error message.
This is what I have:
x, s = hmm.rand(500)
plt.figure(figsize=(10,5))
colors = ['red' if i < 0.5 else 'blue' for i in s]
plt.plot(x[0,0,:], color=colors)
plt.xlabel("t")
plt.ylabel("X[t]")
plt.title("Example output over 500 states")
plt.show()