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

scale_color_gradient

scale_color_gradient applies a color gradient to continuous color variables in your ggplots. Its parameters are:

  • low - low end of the gradient
  • high - high end of the gradient

In [2]:
pigeons.head()


Out[2]:
pos breeder pigeon name color sex ent arrival speed to_win eligible
0 1 Texas Outlaws 19633-AU15-FOYS NaN BCWF H 1 42:14.0 172.155 0:00:00 Yes
1 2 Junior Juanich 0402-AU15-JRL NaN SIWF H 1 47:36.0 163.569 0:05:21 Yes
2 3 Jerry Allensworth 0404-AU15-VITA Perch Potato BB H 1 47:41.0 163.442 0:05:27 Yes
3 4 Alias-Alias 2013-AU15-ALIA NaN BBSP H 1 47:43.0 163.392 0:05:28 Yes
4 5 Greg Glazier 5749-AU15-SLI NaN BC H 1 47:44.0 163.366 0:05:30 Yes

In [3]:
ggplot(pigeons, aes(x='speed', y='pos', color='speed')) + \
    geom_point() + \
    scale_color_gradient()


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

In [4]:
ggplot(pigeons, aes(x='speed', y='pos', color='speed')) + \
    geom_point() + \
    scale_color_gradient(low='blue', high='red')


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

In [5]:
ggplot(pigeons, aes(x='speed', y='pos', color='speed')) + \
    geom_point() + \
    scale_color_gradient(low='FloralWhite', high='LemonChiffon')


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

In [6]:
ggplot(pigeons, aes(x='speed', y='pos', color='speed')) + \
    geom_point() + \
    scale_color_gradient(low='LawnGreen', high='DarkSalmon')


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

In [ ]: