Python Forum
How to fill between the same area with two different colors - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: How to fill between the same area with two different colors (/thread-28183.html)



How to fill between the same area with two different colors - Staph - Jul-08-2020

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')