繁体   English   中英

有没有办法改变 seaborn violin_plot 的颜色

[英]is there a way to change the color of seaborn violin_plot

以下是我的代码:

import seaborn as sns
df = sns.load_dataset('iris')

以下行给了我一把普通的小提琴 plot 与 sepal_length:

sns.violinplot(x = df['species'], y = df['sepal_length'])

output 看起来像这样

物种与萼片长度

现在,我需要更改每个 plot 的颜色,这就是我卡住的地方有没有办法通过留在 seaborn violin_plot 而不进入 ZF02113237A5A5FFF03E34CEE 或任何东西来做到这一点?

答案是使用 seaborn 的pallete的一个简单参数,称为 palette。

以下是代码:

import seaborn as sns
df = sns.load_dataset('iris')
sns.violinplot(x = df['species'], y = df['sepal_length'], palette = ['green', 'blue', 'yellow'])

和 BAM。 完成。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM