Title: Color Palettes in Seaborn
Slug: seaborn_color_palettes
Summary: Color Palettes in Seaborn
Date: 2016-05-01 12:00
Category: Python
Tags: Data Visualization
Authors: Chris Albon

Preliminaries


In [1]:
import pandas as pd
%matplotlib inline
import matplotlib.pyplot as plt
import seaborn as sns

In [2]:
data = {'date': ['2014-05-01 18:47:05.069722', '2014-05-01 18:47:05.119994', '2014-05-02 18:47:05.178768', '2014-05-02 18:47:05.230071', '2014-05-02 18:47:05.230071', '2014-05-02 18:47:05.280592', '2014-05-03 18:47:05.332662', '2014-05-03 18:47:05.385109', '2014-05-04 18:47:05.436523', '2014-05-04 18:47:05.486877'], 
        'deaths_regiment_1': [34, 43, 14, 15, 15, 14, 31, 25, 62, 41],
        'deaths_regiment_2': [52, 66, 78, 15, 15, 5, 25, 25, 86, 1],
        'deaths_regiment_3': [13, 73, 82, 58, 52, 87, 26, 5, 56, 75],
        'deaths_regiment_4': [44, 75, 26, 15, 15, 14, 54, 25, 24, 72],
        'deaths_regiment_5': [25, 24, 25, 15, 57, 68, 21, 27, 62, 5],
        'deaths_regiment_6': [84, 84, 26, 15, 15, 14, 26, 25, 62, 24],
        'deaths_regiment_7': [46, 57, 26, 15, 15, 14, 26, 25, 62, 41]}
df = pd.DataFrame(data, columns = ['date', 'battle_deaths', 'deaths_regiment_1', 'deaths_regiment_2',
                                   'deaths_regiment_3', 'deaths_regiment_4', 'deaths_regiment_5',
                                   'deaths_regiment_6', 'deaths_regiment_7'])
df = df.set_index(df.date)

View some color palettes


In [3]:
sns.palplot(sns.color_palette("deep", 10))



In [4]:
sns.palplot(sns.color_palette("muted", 10))



In [5]:
sns.palplot(sns.color_palette("bright", 10))



In [6]:
sns.palplot(sns.color_palette("dark", 10))



In [7]:
sns.palplot(sns.color_palette("colorblind", 10))



In [8]:
sns.palplot(sns.color_palette("Paired", 10))



In [9]:
sns.palplot(sns.color_palette("BuGn", 10))



In [10]:
sns.palplot(sns.color_palette("GnBu", 10))



In [11]:
sns.palplot(sns.color_palette("OrRd", 10))



In [12]:
sns.palplot(sns.color_palette("PuBu", 10))



In [13]:
sns.palplot(sns.color_palette("YlGn", 10))



In [14]:
sns.palplot(sns.color_palette("YlGnBu", 10))



In [15]:
sns.palplot(sns.color_palette("YlOrBr", 10))



In [16]:
sns.palplot(sns.color_palette("YlOrRd", 10))



In [17]:
sns.palplot(sns.color_palette("BrBG", 10))



In [18]:
sns.palplot(sns.color_palette("PiYG", 10))



In [19]:
sns.palplot(sns.color_palette("PRGn", 10))



In [20]:
sns.palplot(sns.color_palette("PuOr", 10))



In [21]:
sns.palplot(sns.color_palette("RdBu", 10))



In [22]:
sns.palplot(sns.color_palette("RdGy", 10))



In [23]:
sns.palplot(sns.color_palette("RdYlBu", 10))



In [24]:
sns.palplot(sns.color_palette("RdYlGn", 10))



In [25]:
sns.palplot(sns.color_palette("Spectral", 10))


Create a color palette and set it as the current color palette


In [26]:
flatui = ["#9b59b6", "#3498db", "#95a5a6", "#e74c3c", "#34495e", "#2ecc71"]
sns.set_palette(flatui)
sns.palplot(sns.color_palette())


Set the color of a plot


In [27]:
sns.tsplot([df.deaths_regiment_1, df.deaths_regiment_2, df.deaths_regiment_3, df.deaths_regiment_4,
            df.deaths_regiment_5, df.deaths_regiment_6, df.deaths_regiment_7], color="#34495e")


Out[27]:
<matplotlib.axes._subplots.AxesSubplot at 0x116f5db70>