python - Seaborn 箱线图,所有箱子颜色相同

标签 python matplotlib colors seaborn boxplot

我正在使用 seaborn 并想生成一个箱线图,其中所有箱子都具有相同的颜色。出于某种原因,seaborn 为每个框使用不同的颜色,并且没有选项可以停止此行为并为所有框设置相同的颜色。

我如何强制 seaborn 对所有框使用相同的颜色?

fig, ax = plt.subplots(figsize=(10, 20))
sns.boxplot(y='categorical_var', x='numeric_var', ax=ax)

最佳答案

使用color参数:

import seaborn as sns
tips = sns.load_dataset("tips")
sns.boxplot(x="day", y="tip", data=tips, color="seagreen")

enter image description here

关于python - Seaborn 箱线图,所有箱子颜色相同,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43422748/

相关文章:

python - 无法调用canvas.show()

python - sqlalchemy: 'metadata.drop_all' 不工作

python - 在不同的进程中运行 py.test 测试

matplotlib - 刻度线和刻度标签可以放置在轴限制之外吗?

python - Matplotlib 崩溃 tkinter 应用程序

linux - 改变鞭尾鱼的颜色

css - 在 scss 中更改 Material Design Lite 的主题颜色

colors - 将 CMYK 中的颜色转换为十六进制的公式是什么?

python - 在 sqlite 中存储 GUID 的正确方法

python - 在 HTML 中循环字典