【问题标题】:Apply single colors for all bars in seaborn countplot为 seaborn 计数图中的所有条形应用单一颜色
【发布时间】:2020-05-30 14:45:34
【问题描述】:

以下代码为每个类别提供不同的颜色

import seaborn as sns
sns.set(style="darkgrid")
titanic = sns.load_dataset("titanic")
ax = sns.countplot(x="class", data=titanic)

如何使它们都具有相同的颜色?

【问题讨论】:

  • 喜欢 sns.countplot(x="class",data=titanic,color="k")
  • @Sheldore 谢谢,在stackoverflow.com/questions/62103220/…,你发了plt.close(2),你能再发一次吗?我愿意接受(我看到你删除了答案,但不确定是谁投了反对票)。

标签: matplotlib seaborn


【解决方案1】:

documentation:

seaborn.countplot(x=None, y=None, hue=None, data=None, order=None, hue_order=无,方向=无,颜色=无,调色板=无, 饱和度=0.75, 闪避=True, ax=None, **kwargs)

函数接受颜色参数,改变它来改变颜色。

【讨论】:

    猜你喜欢
    • 2018-11-26
    • 2021-08-18
    • 2023-03-29
    • 2022-01-11
    • 2020-01-30
    • 1970-01-01
    • 1970-01-01
    • 2021-12-10
    • 2015-04-06
    相关资源
    最近更新 更多