In [1]:
%matplotlib inline
from ggplot import *

scale_color_brewer

scale_color_brewer applies color palettes to discrete color variables in your ggplots. It has 2 parameters:

  • type - type of palette to use ('diverging/div', 'qualitative/qual', 'sequential/seq')
  • palette - palette number

In [2]:
ggplot(mtcars, aes(x='wt', y='mpg', color='factor(cyl)')) + geom_point()


Out[2]:
<ggplot: (284441529)>

In [3]:
ggplot(mtcars, aes(x='wt', y='mpg', color='factor(cyl)')) + \
    geom_point() + \
    scale_color_brewer()


Out[3]:
<ggplot: (285303209)>

In [4]:
ggplot(mtcars, aes(x='wt', y='mpg', color='factor(cyl)')) + \
    geom_point() + \
    scale_color_brewer(type='div')


Out[4]:
<ggplot: (285330073)>

In [5]:
ggplot(mtcars, aes(x='wt', y='mpg', color='factor(cyl)')) + \
    geom_point() + \
    scale_color_brewer(type='div', palette=4)


Out[5]:
<ggplot: (284723677)>

In [6]:
ggplot(mtcars, aes(x='wt', y='mpg', color='factor(cyl)')) + \
    geom_point() + \
    scale_color_brewer(type='seq', palette=2)


Out[6]:
<ggplot: (285179185)>

In [7]:
ggplot(mtcars, aes(x='wt', y='mpg', color='factor(cyl)')) + \
    geom_point() + \
    scale_color_brewer(type='qual')


Out[7]:
<ggplot: (285608533)>

In [ ]: