2017-12-28 3 views
-1

내 막대 차트에서 각 막대의 색상을 변경하는 데 문제가 있습니다. 'Administrative &', 'Others'를 다른 것으로 변경하고 싶습니다. 색상 도움 .. 내 현재 코드는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) 

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() 

output image

답변

0
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() 

그것을

있어
관련 문제