7

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?

Example:

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

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.

JoshuaA
  • 279
  • 4
  • 11
  • 1
    Did you try specifying `kde_kws`/`hist_kws`? https://web.stanford.edu/~mwaskom/software/seaborn/generated/seaborn.distplot.html – Caramiriel Oct 07 '15 at 13:04
  • I changed my plot command to this: `g = sns.distplot(x, hist_kws={"alpha": 1, "color": current_palette})` It works great! Thanks! – JoshuaA Oct 07 '15 at 13:40

2 Answers2

4

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

Two answers referencing ways to modify matplotlib object transparency:

Community
  • 1
  • 1
ebyerly
  • 662
  • 5
  • 14
2

seaborn.distplot allows you to pass different parameters for styling (*_kws). Each plot function has it's own parameters and are therefor prefixed by the name of the plot. Eg. histogram has hist_kws. [distplot Reference]

Because the histogram plot is located in matplotlib, we'd have to look at the keyword parameters we can pass. Like you already figured out, you can pass the 'alpha' keyword parameter to get rid of the transparancy of the lines. See reference for more arguments (kwargs section). [pyplot Reference]

Caramiriel
  • 7,029
  • 3
  • 30
  • 50