Seaborn chart colors are different than those specified by palette

自作多情 提交于 2019-11-29 15:18:07

Many seaborn plotting commands have an argument saturation, whose default value is 0.75. It sets the saturation (S) of the colors in the HSL colorspace (ranging from 0 to 1) to the given value.

Setting this parameter to 1 in the countplot will give you the same colors in both plots.

ax = sns.countplot(x="class", data=titanic, palette=sns.xkcd_palette(colors), saturation=1)
sns.palplot(sns.xkcd_palette(colors))

The reason for this default desaturation is that many people consider a plot with less contrast to be more appealing. That is also why the default background in seaborn is not white but some bluish gray. After all, this is of course a question of taste.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!