在pandas/matplotlib/seaborn python中使用自定义配色方案 [英] using a custom colour scheme in pandas/matplotlib/seaborn python

查看:88
本文介绍了在pandas/matplotlib/seaborn python中使用自定义配色方案的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想为各种地块使用自定义配色方案,但无法使其正常工作(对这些地块使用seaborn和/或matplob& pandas)

I want to use a custom colour scheme using for various plots but can't get it to work (using seaborn and/or matplob & pandas for these plots)

flatui = ["#9b59b6", "#3498db", "#95a5a6", "#e74c3c", "#34495e", "#2ecc71"]
ax = sns.violinplot(x="Contents", y="Flavour", data=rd, color="lol", inner="box")

我收到错误代码:

ValueError: to_rgb: Invalid rgb arg "flatui"
could not convert string to float: 'flatui'

ax = sns.violinplot(x="Contents", y="Flavour", data=rd, color=["9b59b6", "#3498db", "#95a5a6", "#e74c3c", "#34495e", "#2ecc71"], inner="box")

不工作

请帮助!

推荐答案

让我们尝试一下.

flatui = ["#9b59b6", "#3498db", "#95a5a6", "#e74c3c", "#34495e", "#2ecc71"]
sns.set_palette(flatui)
sns.palplot(sns.color_palette())

ax = sns.violinplot(x="Contents", y="Flavour", data=rd, color="lol", inner="box")

这里有一些其他数据.

这篇关于在pandas/matplotlib/seaborn python中使用自定义配色方案的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆