Reputation: 3754
I'm trying to figure out how to set y names to match the color of the barplot that corresponds to it. So every publisher name has the same color as the bar next to it, like PS2 will be pink, 3DS green and so on.
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)
Upvotes: 1
Views: 389
Reputation: 339052
You can iterate over the ticklabels and set the respective color from the palette.
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
l =list("ABCDEFGHIJK")
x = np.arange(1,len(l)+1)[::-1]
f, ax=plt.subplots(figsize=(7,7))
sns.barplot(x=x,y=l, palette='husl', ax=ax)
plt.ylabel('Publisher', color='deepskyblue', size=15, alpha=0.8)
plt.xlabel('Number of titles published', color='slateblue', size=15, alpha=0.7)
p = sns.color_palette("husl", len(l))
for i, label in enumerate(ax.get_yticklabels()):
label.set_color(p[i])
plt.show()
Upvotes: 1