To fill between two curves in pandas, you can use the .fill_between()
method provided by matplotlib
. First, you need to plot the two curves using pandas, then get the current axis and pass it to fill_between()
method. Here's an example:
main.py513 chars22 lines
This will create a plot with two curves and fill between them where y1 >= y2
with green color and where y1 < y2
with red color. You can adjust the interpolate
parameter to change the style of filling between the curves.
gistlibby LogSnag