def save_graphs(self, year):
     plt.close('all')
     year_data = merge_by_year(int(year))
     label = "Per capita incomes in " + self.region + ' in ' + str(year)
     data = year_data[year_data.Region == self.region].reset_index()
     
     plt.boxplot(data['Income'])
     plt.xlabel(label)
     plt.ylabel('Income Distribution')
     plt.savefig(str(self.region) + ' income per capita boxplot from ' + str(year) + '.pdf', format='pdf')
     plt.close('all')
     
     plt.hist(data['Income'].dropna())
     plt.xlabel(label)
     plt.ylabel('Number of countries')
     plt.savefig(str(self.region) + ' income per capita histogram from ' + str(year) +'.pdf', format='pdf')
Beispiel #2
0
 def testMerge(self):
     for i in enumerate(range(10)):
         a = graph_functions.merge_by_year(random.randrange(1800,2013,1))
         self.assertEqual(a.ix[0][1], 'AFRICA')
         self.assertEqual(a.ix[100][0], 'Finland')
Beispiel #3
0
 def testMerge(self):
     for i in enumerate(range(10)):
         a = graph_functions.merge_by_year(random.randrange(1800, 2013, 1))
         self.assertEqual(a.ix[0][1], 'AFRICA')
         self.assertEqual(a.ix[100][0], 'Finland')