%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 numberggplot(mtcars, aes(x='wt', y='mpg', color='factor(cyl)')) + geom_point()
ggplot(mtcars, aes(x='wt', y='mpg', color='factor(cyl)')) + \
geom_point() + \
scale_color_brewer()
ggplot(mtcars, aes(x='wt', y='mpg', color='factor(cyl)')) + \
geom_point() + \
scale_color_brewer(type='div')
ggplot(mtcars, aes(x='wt', y='mpg', color='factor(cyl)')) + \
geom_point() + \
scale_color_brewer(type='div', palette=4)
ggplot(mtcars, aes(x='wt', y='mpg', color='factor(cyl)')) + \
geom_point() + \
scale_color_brewer(type='seq', palette=2)
ggplot(mtcars, aes(x='wt', y='mpg', color='factor(cyl)')) + \
geom_point() + \
scale_color_brewer(type='qual')