merged in all the code from ariel's branches and moved wikibios to a subdir
[matplotlib-cdsw] / wikibios / histograms.py
1 """Make combined histograms of the male and female articles, by birth year and first edit date."""
2 import wikibios
3 from matplotlib import pyplot, dates
4
5 figure = pyplot.figure()
6
7 axes1 = figure.add_subplot(2, 1, 1)
8 birth_years_male = wikibios.columns_male['birth_year']
9 birth_years_female =  wikibios.columns_female['birth_year']
10 axes1.hist([birth_years_female, birth_years_male], bins=50, stacked=True, range=[1514, 2014])
11 axes1.set_xlabel('Birth Year')
12 axes1.set_ylabel('Articles')
13
14 axes2 = figure.add_subplot(2, 1, 2)
15 firstedits_male = dates.date2num(wikibios.columns_male['firstedit'])
16 firstedits_female = dates.date2num(wikibios.columns_female['firstedit'])
17 axes2.hist([firstedits_female, firstedits_male], bins=50, stacked=True, label=['Female', 'Male'])
18 axes2.xaxis.set_major_formatter(dates.AutoDateFormatter(dates.AutoDateLocator()))
19 axes2.legend()
20 axes2.set_xlabel('Article Year')
21 axes2.set_ylabel('Articles')
22
23 figure.savefig('histograms.pdf')

Benjamin Mako Hill || Want to submit a patch?