Table of Contents
To change the color of a Seaborn histogram, first import the Seaborn library into your Python code. Then, use the “color” parameter within the “sns.distplot()” function to specify the desired color. This allows for customization of the histogram’s color to better suit the visual representation of the data. Additionally, you can use the “palette” parameter to choose from a variety of pre-defined color palettes or create a custom color palette using the “sns.color_palette()” function. By utilizing these methods, the color of a Seaborn histogram can be easily changed to enhance the overall presentation of the data.
Change the Color of a Seaborn Histogram
You can use the color and edgecolor arguments in seaborn to change the fill color and outline color, respectively, of bars in a histogram:
sns.histplot(data=df, x='some_variable', color='orange', edgecolor='red')
The following example shows how to use these arguments in practice.
Example: Change Colors of Seaborn Histogram
Suppose we have the following pandas DataFrame that contains information about the points scored by 200 different basketball players:
import pandas as pd
import numpy as np
#make this example reproducible
np.random.seed(1)
#create DataFrame
df = pd.DataFrame({'team': np.repeat(['A', 'B'], 100),
'points': np.random.normal(size=200, loc=15, scale=4)})
#view head of DataFrame
print(df.head())
team points
0 A 21.497381
1 A 12.552974
2 A 12.887313
3 A 10.708126
4 A 18.461631We can use the following code to create a histogram in seaborn to visualize the distribution of values in the points column:
import seaborn as sns #create histogram to visualize distribution of points sns.histplot(data=df, x='points')

By default, seaborn uses blue as the fill color and black as the outline color for the bars in the histogram.
However, we can customize these colors by using the color and edgecolor arguments:
import seaborn as sns #create histogram to visualize distribution of points sns.histplot(data=df, x='points', color='orange', edgecolor='red')

Notice that the histogram now has a fill color of orange and and outline color of red.
Also note that you can use hex color codes for even more customization:
import seaborn as sns #create histogram to visualize distribution of points sns.histplot(data=df, x='points', color='#DAF7A6', edgecolor='#BB8FCE')

The following tutorials explain how to perform other common functions in seaborn:
Cite this article
stats writer (2024). How can I change the color of a Seaborn histogram?. PSYCHOLOGICAL SCALES. Retrieved from https://scales.arabpsychology.com/stats/how-can-i-change-the-color-of-a-seaborn-histogram/
stats writer. "How can I change the color of a Seaborn histogram?." PSYCHOLOGICAL SCALES, 25 Jun. 2024, https://scales.arabpsychology.com/stats/how-can-i-change-the-color-of-a-seaborn-histogram/.
stats writer. "How can I change the color of a Seaborn histogram?." PSYCHOLOGICAL SCALES, 2024. https://scales.arabpsychology.com/stats/how-can-i-change-the-color-of-a-seaborn-histogram/.
stats writer (2024) 'How can I change the color of a Seaborn histogram?', PSYCHOLOGICAL SCALES. Available at: https://scales.arabpsychology.com/stats/how-can-i-change-the-color-of-a-seaborn-histogram/.
[1] stats writer, "How can I change the color of a Seaborn histogram?," PSYCHOLOGICAL SCALES, vol. X, no. Y, ص Z-Z, June, 2024.
stats writer. How can I change the color of a Seaborn histogram?. PSYCHOLOGICAL SCALES. 2024;vol(issue):pages.
