You need to use color
instead of facecolor
. You can also specify color as a list instead of a scalar value. So for your example, you could have color=['r','b','b','b','b']
For example,
import numpy as np
import matplotlib.pyplot as plt
fig = plt.figure()
ax = fig.add_subplot(111)
N = 5
ind = np.arange(N)
width = 0.5
vals = [1,2,3,4,5]
colors = ['r','b','b','b','b']
ax.barh(ind, vals, width, color=colors)
plt.show()
is a full example showing you what you want.
To answer your comment:
colors = []
for value in dictionary.keys(): # keys are the names of the boys
if winner == value:
colors.append('r')
else:
colors.append('b')
bar(ind,num,width,color=colors)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…