I'm using matplotlib to create a simple line plot. My plot is a simple time-series data set where I have time along the x-axis and the value of something I am measuring on the y-axis. y values can have postitive or negative values and I would like to fill in the area above and below my line with the color blue if the y-value is > 0 and red if the y values is < 0. Here's my plot:

As you can see, I can get the blue color to fill in correctly, but I can not get the red color to fill in properly. Here's the basic code I am using:
plt.plot(x, y, marker='.', lw=1)
d = scipy.zeros(len(y))
ax.fill_between(xs,ys,where=ys>=d, color='blue')
ax.fill_between(xs,0,where=ys<=d, color='red')
How can I get the area from a positive y-value to the x-axis to be blue and the area from a negative y-value to the x-axis to be red? Thanks for the help.
ax.fill_between(xs,ys,where=ys<=d, color='red'), as you are now trying to fill the area betweeny1=0andy2=0(i.e. no area). The second argument (in this caseys) is passed to they1parameter, and sincey2has default value0, the method will fill the area between the array you have specified fory1and the line y=0, which is what you want. - soddax.fill_between(xs,ys,where=ys<=d, interpolate=True, color='red'). Theinterpolateparameter makes the function interpolate to find the intersection between they1andy2arrays, as to get a "smoother" plot. - sodd