Python Forum

Full Version: How to fill between the same area with two different colors
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
import matplotlib.pyplot as plt
x1 = [1,2,3,4,5,]
y1 = [2,3,4,5,6]
y2 = [6,7,8,9,10]

x2 = [6,7,8,9,10]
y11 = [2,3,4,5,6]
y22 = [10,11,12,12,5]

instead of plottig them separately like this

plt.fill_between(x1,y1,y2, c='g')
plt.fill_between(x2,y11,y22, c='r')

I want to be able to combine them and plot with two different colors like this

plt.fill_between([x1:x2], [y1:y2], [y11:y22], c='g', c='r')