设置yticks颜色以匹配barplot颜色python

时间:2017-03-12 16:35:21

标签: python matplotlib seaborn

我正在试图弄清楚如何设置y名称以匹配与其对应的条形图的颜色。因此,每个出版商名称都与其旁边的栏具有相同的颜色,例如PS2将是粉红色,3DS绿色等等。

f, ax=plt.subplots(figsize=(7,7))
sns.barplot(x=gbyplat,y=gbyplat.index, palette='husl')
plt.ylabel('Publisher', color='deepskyblue', size=15, alpha=0.8)
plt.xlabel('Number of titles published', color='slateblue', size=15, alpha=0.7)

image

1 个答案:

答案 0 :(得分:1)

您可以遍历ticklabels并从调色板中设置相应的颜色。

enter image description here

BadImageFormatException