Intro to MatPlotLib with wikipedia biography metadata
[matplotlib-cdsw] / scatterplot.py
1 """Make a scatterplot of male and female articles."""
2 import wikibios
3 from datetime import datetime
4 from matplotlib import pyplot
5
6 figure = pyplot.figure()
7 axes = figure.gca()
8
9 firstedits_male = wikibios.columns_male['firstedit']
10 birth_years_male = wikibios.columns_male['birth_year']
11 axes.scatter(firstedits_male, birth_years_male, alpha=0.1, c='green', linewidths=(0,), label='Male')
12
13 firstedits_female = wikibios.columns_female['firstedit']
14 birth_years_female = wikibios.columns_female['birth_year']
15 axes.scatter(firstedits_female, birth_years_female, alpha=0.1, c='orange', linewidths=(0,), label='Female')
16 axes.set_xlabel('Article Date')
17 axes.set_ylabel('Birth Year')
18 axes.legend()
19 figure.savefig('scatter.png')

Benjamin Mako Hill || Want to submit a patch?