如何在matplotlib条形图(python)中更改/设置多个条形图颜色

如何在matplotlib条形图(python)中更改/设置多个条形图颜色,python,python-3.x,numpy,dataframe,matplotlib,Python,Python 3.x,Numpy,Dataframe,Matplotlib,我在更改条形图中每个条形图的颜色时遇到问题 我想将“管理和支持人员”和“其他人”更改为不同颜色的帮助。。 我现在的代码是 import seaborn as sns sns.set() ax1 = tt.plot(kind='bar', figsize=(20,10), fontsize=13) #legend = plt.legend(loc=2, fontsize=8) for tick in ax1.get_xticklabels(): tick.set_rotation(0)

我在更改条形图中每个条形图的颜色时遇到问题 我想将“管理和支持人员”和“其他人”更改为不同颜色的帮助。。 我现在的代码是

import seaborn as sns
sns.set()

ax1 = tt.plot(kind='bar', figsize=(20,10), fontsize=13)
#legend = plt.legend(loc=2, fontsize=8)
for tick in ax1.get_xticklabels():
    tick.set_rotation(0)

ax1.legend(loc='upper center', bbox_to_anchor=(0.5, -0.05),
          fancybox=True, shadow=True, ncol=5)
# ax1 = plt.gca()
# leg = ax1.get_legend()
# leg.legendHandles[1].set_color('yellow')

plt.show()

明白了

import seaborn as sns
sns.set()

ax1 = tt.plot(kind='bar', figsize=(20,10), fontsize=13, color = ['#1b9e77', '#a9f971', '#fdaa48'])

for tick in ax1.get_xticklabels():
    tick.set_rotation(0)

ax1.legend(loc='upper center', bbox_to_anchor=(0.5, -0.05),
          fancybox=True, shadow=True, ncol=5)


plt.show()