Python Seaborn:指定确切的颜色

Python Seaborn:指定确切的颜色,python,matplotlib,ipython-notebook,seaborn,Python,Matplotlib,Ipython Notebook,Seaborn,您可以为打印指定颜色,但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

您可以为打印指定颜色,但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)


我在Seaborn中尝试了几种指定颜色和所有可用样式的方法,但都不起作用。我正在使用iPython笔记本电脑和Python 2.7。

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

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


    • seaborn.distplot
      允许您为样式传递不同的参数(
      *\u kws
      )。每个绘图函数都有自己的参数,因此以绘图名称作为前缀。例如,直方图有
      hist\u kws
      。[]


      因为直方图图位于matplotlib中,所以我们必须查看可以传递的关键字参数。正如您已经想到的,您可以传递'alpha'关键字参数来消除行的透明度。有关更多参数,请参见参考(kwargs部分)。[]您是否尝试指定了
      kde_-kws
      /
      hist_-kws
      ?我将plot命令改为:
      g=sns.distplot(x,hist_kws={“alpha”:1,“color”:current_palete})
      它工作得很好!谢谢
      # Show what the color should look like
      sns.palplot(current_palette)