本文介绍了Seaborn:指定确切的颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您可以为绘图指定颜色,但是Seaborn在绘图期间会略微减弱颜色.有没有办法关闭这种行为?

You can specify a color for plots, but Seaborn will mute the color a bit during plotting. Is there a way to turn off this behavior?

示例:

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)
# Show what the color should look like
sns.palplot(current_palette)

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

I have tried several ways of specifying the color and all available styles in Seaborn, but nothing has worked. I am using iPython notebook and Python 2.7.

推荐答案

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

It is not using a muted color, its using an alpha/transparency value as part of the default.

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

Two answers referencing ways to modify matplotlib object transparency:

  • https://stackoverflow.com/a/4708018
  • https://stackoverflow.com/a/24549558

这篇关于Seaborn:指定确切的颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-24 04:33