def plot_hist(data, dim, level): # TODO(ipince): which bins to use? #utils.hist_wrap((data, range(int(min(data)), int(max(data)))), utils.hist_wrap((data, 200), title='%s diff by %s' % (dim, level), xlabel='%s_2013 - %s_2012' % (dim, dim), ylabel='frequency', filename='%s_diff_hist_by_%s.png' % (dim, level)) # save a zoomed-in copy plt.ylim(0, 20) plt.draw() plt.savefig('%s_diff_hist_by_%s_zoom.png' % (dim, level))
plot_benford_2nd(states, 'state') plot_benford_2nd(munis, 'muni') plot_benford_2nd(parishes, 'parish') plot_benford_2nd(centers, 'center') plot_benford_2nd(tables, 'table') plot_all_benford() print "min for cap2013 is %d" % min([tables[1][code]['cap'] for code in tables[1]]) print "max for cap2013 is %d" % max([tables[1][code]['cap'] for code in tables[1]]) print "min for gov2013 is %d" % min([tables[1][code]['gov'] for code in tables[1]]) print "max for gov2013 is %d" % max([tables[1][code]['gov'] for code in tables[1]]) print "min for voters is %d" % min([tables[1][code]['voters'] for code in tables[1]]) print "max for voters is %d" % max([tables[1][code]['voters'] for code in tables[1]]) utils.hist_wrap(([tables[1][code]['voters'] for code in tables[1]], 200), filename='table-voters.png') utils.hist_wrap(([tables[1][code]['cap'] for code in tables[1]], 200), filename='table-cap.png') utils.hist_wrap(([tables[1][code]['gov'] for code in tables[1]], 200), filename='table-gov.png') utils.hist_wrap(([centers[1][code]['voters'] for code in centers[1]], 200), filename='center-voters.png') import matplotlib.pyplot as plt plt.figure() plt.hist([centers[1][code]['voters'] for code in centers[1]], 200, cumulative=True) plt.show() plt.savefig('center-cum_hist.png') plt.figure() plt.hist([tables[1][code]['voters'] for code in tables[1]], 200, cumulative=True) plt.show() plt.savefig('table-cum_hist.png') utils.hist_wrap(([centers[1][code]['cap'] for code in centers[1]], 200), filename='center-cap.png') utils.hist_wrap(([centers[1][code]['gov'] for code in centers[1]], 200), filename='center-gov.png')