• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

Data Viz with Python and R

Learn to Make Plots in Python and R

  • Home
  • Seaborn
  • Matplotlib
  • ggplot2
  • Altair
  • About
    • Privacy Policy
  • Visualizing Activation Functions in Neural Networks
  • Confusion Matrix Calculator
  • Visualizing Dropout Rate in Neural Network
  • Visualizing Loss Functions in Neural Networks
  • Show Search
Hide Search

How to Add Outline/Edge Color to Histogram in Seaborn?

datavizpyr · January 7, 2020 ·

Last updated on January 4, 2020

In this tutorial, we will see an example of adding edge color/edge line to histograms made with Seaborn.

Let us load the packages needed to make histogram with outlines using Seaborn.

 
import seaborn as sns 
import matplotlib.pyplot as plt
import pandas as pd
import numpy as np

We will use Seattle weather data from vega_datasets to make histograms.

 
from vega_datasets import data
seattle_weather = data.seattle_weather()
print(seattle_weather.head(n=3))

Let us first make a histogram with Seaborn’s distplot.

 
sns.distplot(seattle_weather['temp_max'])
plt.title('Seattle Weather Data', fontsize=18)
plt.xlabel('temp_max', fontsize=16)
plt.ylabel('Density', fontsize=16)

By default, distplot() fills the bars in histogram with blue color. However, it does not have any outline to the edges of the bar. And thus makes the histogram bars look continuous.

Basic Histogram without edge line: Seaborn
Basic Histogram without edge color: Seaborn

We can add outline or edge line with colors using hist_kws as argument to distplot() function. We should specify hist_kws as dictionary with properties for it. For example, in our example we specify the edgecolor and linewidth.

 
sns.distplot(seattle_weather['temp_max'],
             hist_kws=dict(edgecolor="black", linewidth=2))
plt.title('Seattle Weather Data', fontsize=18)
plt.xlabel('temp_max', fontsize=16)
plt.ylabel('Density', fontsize=16)
Add Edge Color to Histogram with Seaborn
Histogram with edge line: Seaborn

Related posts:

Overlapping histogram comparing penguin flipper lengths by speciesHistograms with Seaborn in Python Grouped Barplot with SeabornHow To Make Grouped Barplots in Python with Seaborn? How To Manually Order Boxplot with Seaborn?How To Manually Order Boxplot in Seaborn? Grouped Boxplot with Jittered Data Points SeabornGrouped Boxplot with Jittered Points with Seaborn Python

Filed Under: Histogram with Edge Color Seaborn, Python Tagged With: Histogram, Python, Seaborn

Primary Sidebar

Python & R Viz Hubs

  • Seaborn Guide & Cookbook
  • ggplot2 Guide & Cookbook
  • Matplotlib Guide & Cookbook
  • Confusion Matrix Calculator
  • Visualizing Activation Functions
  • Visualizing Dropout
  • Visualizing Loss Functions

Buy Me a Coffee

Copyright © 2026 · Daily Dish Pro on Genesis Framework · WordPress · Log in

Go to mobile version