I need to give the conditional color in matplotlib bar graph. I tried alot to find the solution but no luck. Could you please help me? Below is my code. Basically I need Green color bar when performance >=8 , yellow when performance <8 & >=4 and red when performance >4.
import matplotlib.pyplot as plt; plt.rcdefaults()
import numpy as np
import matplotlib.pyplot as plt
objects = ('Python', 'C++', 'Java', 'Perl', 'Scala', 'Lisp')
y_pos = np.arange(len(objects))
performance = [10,8,6,4,2,1]
plt.bar(y_pos, performance, align='center', alpha=0.5,color='green')
plt.xticks(y_pos, objects)
plt.ylabel('Usage')
plt.xticks(rotation=90)
plt.title('Programming language usage')
for x,y in zip(y_pos,performance):
plt.text(x, y+0.05, '%.2f' % y, ha='center', va= 'bottom')
plt.show()