You can use numpy
to create your data to plot your curve and then use fill_between()
function of pyplot
from matplotlib
to color the area between curve and x-axis. The area color can be green if it's positive and red if it's negative. Here is an example:
main.py419 chars19 lines
This code will plot the curve and color the area under curve green when it's positive and red when it's negative. You can adjust the alpha
parameter to control the transparency of the color.
gistlibby LogSnag