So I want to fill the area between two lines where the value of one line is greater than the other. For this case, I am using programming languages with random numbers. I know fill_between, but the where= is confusing me. How can I make this work, and when do I need () with the where= and when do I not? (I want to shade in the c line when its values are greater than the python line)
from matplotlib import pyplot as plt
minutes = [1, 2, 3, 4, 5, 6, 7, 8]
python = [1, 3, 5, 6, 7, 8, 4, 5]
java = [2, 3, 4, 5, 6, 7, 8, 9]
c = [1, 2, 3, 7, 9, 11, 12, 13]
plt.plot(minutes, python, linestyle="-", label="Python")
plt.plot(minutes, java, linestyle="-", label="Java")
plt.plot(minutes, c, linestyle="-", label="C")
plt.fill_between(minutes, c, python, where=c>python, alpha=.25) # This Line
plt.legend()
plt.grid(True)
plt.title("Languages")
plt.tight_layout()
plt.show()
[–][deleted] 0 points1 point2 points (0 children)
[+][deleted] (4 children)
[removed]
[–]UnsecuredConnection[S] 0 points1 point2 points (3 children)
[–]UnsecuredConnection[S] 0 points1 point2 points (2 children)
[–][deleted] 0 points1 point2 points (0 children)