In [1]:
import ggplot as gg
import ultrasignup as us
import numpy as np

In [2]:
d = us.event_results(299)

In [3]:
d.head()


Out[3]:
age agegroup bib city firstname formattime gender gender_place lastname participant_id place runner_rank state status time time_hour year distance
0 26 20-29 Chattanooga Daniel 4:25:28 M 1 Hamilton 274774 1 93.18 TN 1 15928 4.424444 2014 50K
1 27 20-29 Clarksville Kyle 4:29:22 M 2 Curtin 512120 2 90.56 TN 1 16162 4.489444 2014 50K
2 33 30-39 Ogden Joshua 4:32:01 M 3 Korn 418055 3 87.56 UT 1 16321 4.533611 2014 50K
3 20 20-29 Roswell Alec 4:39:55 M 4 Blenis 380104 4 89.18 GA 1 16795 4.665278 2014 50K
4 28 20-29 Auburn William 4:41:59 M 5 Ansick 1561 5 80.48 AL 1 16919 4.699722 2014 50K

In [4]:
%matplotlib inline
p1 = gg.ggplot(
  gg.aes(x='time_hour',fill='gender'),d[(d.distance=='50K')&(d.time_hour>1.0)]) + \
  gg.facet_grid(x='gender') + \
  gg.geom_bar(stat="bin",binwidth=.5,position="dodge",colour="black") + \
  gg.xlab("Time (hours)") + gg.ylab("Number of Finishers") + \
  gg.ggtitle("50K Finishing Times for All Years")
print(p1)


/home/jeffrey/anaconda3/lib/python3.4/site-packages/ggplot/ggplot.py:200: RuntimeWarning: Facetting is currently not supported with geom_bar. See
                    https://github.com/yhat/ggplot/issues/196 for more information
  warnings.warn(msg, RuntimeWarning)
<ggplot: (-9223363269044096922)>

In [5]:
%matplotlib inline
p2 = gg.ggplot(
  gg.aes(x='time_hour',fill='gender'),d[(d.distance=='11 Miler')&(d.time_hour>1.0)]) + \
  gg.facet_grid(x='gender') + \
  gg.geom_bar(stat="bin",binwidth=.5,position="dodge",colour="black") + \
  gg.xlab("Time (hours)") + gg.ylab("Number of Finishers") + \
  gg.ggtitle("11M Finishing Times for All Years")
print(p2)


/home/jeffrey/anaconda3/lib/python3.4/site-packages/ggplot/ggplot.py:200: RuntimeWarning: Facetting is currently not supported with geom_bar. See
                    https://github.com/yhat/ggplot/issues/196 for more information
  warnings.warn(msg, RuntimeWarning)
<ggplot: (-9223363269014736103)>