gpt4 book ai didi

python - Seaborn:指定确切的颜色

转载 作者:太空狗 更新时间:2023-10-29 21:45:55 25 4
gpt4 key购买 nike

您可以为绘图指定颜色,但 Seaborn 会在绘图过程中稍微淡化颜色。有没有办法关闭此行为?

例子:

import matplotlib
import seaborn as sns
import numpy as np

# Create some data
np.random.seed(0)
x = np.random.randn(100)

# Set the Seaborn style
sns.set_style('white')

# Specify a color for plotting
current_palette = matplotlib.colors.hex2color('#86b92e')

# Make a plot
g = sns.distplot(x, color=current_palette)

Histogram with muted color

# Show what the color should look like
sns.palplot(current_palette)

What the color should look like

我尝试了几种方法来指定 Seaborn 中的颜色和所有可用样式,但没有任何效果。我正在使用 iPython notebook 和 Python 2.7。

最佳答案

它没有使用柔和的颜色,而是使用 alpha/透明度值作为默认值的一部分。

两个引用修改 matplotlib 对象透明度的方法的答案:

关于python - Seaborn:指定确切的颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32992773/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com