Let's say I want to make a bar plot where the hue of the bars represents some continuous quantity. e.g.
import seaborn as sns
titanic = sns.load_dataset("titanic")
g = titanic.groupby('pclass')
survival_rates = g['survived'].mean()
n = g.size()
ax = sns.barplot(x=n.index, y=n,
hue=survival_rates, palette='Reds',
dodge=False,
)
ax.set_ylabel('n passengers')
The legend here is kind of silly, and gets even worse the more bars I plot. What would make most sense is a colorbar (such as are used when calling sns.heatmap
). Is there a way to make seaborn do this?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…