jeudi 14 juillet 2016

How can I change the linecolor if y-value changes


I'm using pylab to plot some graphs Say I want to plot this:

x = [0,1,2,3,4,5,6,7,8,9,10]
y = [0,0,0,1,1,0,0,1,0,0,0]

plt.plot(x,y,'g')
plt.show()

But every time [y = 1] I want to change the color of the line to red.

Is this possible?

Sketch of what I want to accomplish


Aucun commentaire:

Enregistrer un commentaire