【发布时间】:2016-01-04 17:12:30
【问题描述】:
您可以为绘图指定颜色,但 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)
# Show what the color should look like
sns.palplot(current_palette)
我尝试了几种在 Seaborn 中指定颜色和所有可用样式的方法,但没有任何效果。我正在使用 iPython 笔记本和 Python 2.7。
【问题讨论】:
-
您是否尝试指定
kde_kws/hist_kws? web.stanford.edu/~mwaskom/software/seaborn/generated/… -
我将绘图命令更改为:
g = sns.distplot(x, hist_kws={"alpha": 1, "color": current_palette})效果很好!谢谢!
标签: python matplotlib ipython-notebook seaborn