I can't seem to figure out how to change linecolor in matplotlib based on some simple logic.
For instance,let's say I have:
import numpy as np
from matplotlib import pyplot as plt
A = [1,2,3,4,5]
B = [2,4,6,8,10]
C = [1,3,5,6,7]
D = [1,2,3,3,3]
combined = [A,B,C,D]
Now, let's say I want matplotlib to plot this as a line graph. Thus, there should be 4 separate lines based on each list in combined.
I want to add the condition if a number in list (of combined) is greater than 5 then the individual line be blue. Else, let the individual line be orange.
How do I go about doing something like this? I know the following would plot it just fine.
np_combined = np.array(combined)
times = np.linspace(0,1,5)
plt.plot(times,np_combined.T)
Would I need a double for loop? I tried more than a few, but seem to end up getting an error each time.
for h in np_combined:
for k in range(5):
if k > 5:
plt.plot(times,k,color = 'blue')
else:
plt.plot(times,k,color = 'orange')
Error is EOL while scanning string literal